Skip to content

Instantly share code, notes, and snippets.

@martinyung
Last active September 9, 2017 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinyung/63feb9587feec6d77270973395e29fb4 to your computer and use it in GitHub Desktop.
Save martinyung/63feb9587feec6d77270973395e29fb4 to your computer and use it in GitHub Desktop.
[blogging purpose] grails upload controller
package [Your_Project]
class UploadController {
def amazonS3Service
def s3Bucket = 'Your_S3_Bucket_Name'
def index() {
def uploadedFile = request.getFile('file')
if (uploadedFile && !uploadedFile.empty) {
def key = uploadedFile.getOriginalFilename()
// push uploaded file to S3
amazonS3Service.storeMultipartFile(s3Bucket, key, uploadedFile)
log.debug "written to s3"
} else {
log.debug "No file uploaded"
}
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment