First, we need to add plugin dependency to your
'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
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.
Add method to controller:
Add this to UrlMappings:
To store image on amazon send POST request: