How to upload image on Amazon with Grails RESTful API

with No Comments

First, we need to add plugin dependency to your build.gradle:
compile 'org.grails.plugins:aws-sdk-s3:2.0.3'

'org.grails.plugins:aws-sdk-s3:2.0.3' – this plugin adds support for Amazon Simple Storage Service (Amazon S3), which provides developers and IT teams with secure, durable, highly-scalable cloud storage.
Also we need to add library for work with files
compile "commons-io:commons-io:2.4".
Then we need to create an AWS account Amazon Web Services, in order to get your own credentials accessKey and secretKey.
Then add your AWS credentials parameters to your grails-app/conf/application.yml:

Or you can add it to your grails-app/conf/application.groovy:

The default region used is us-east-1. You might override it in your config.
For example we create a simple project.

 

domain Attachment:

Add method to controller:

In  ImageService:

Add this to UrlMappings:

To store image on amazon send POST request:

Leave a Reply