Last active
September 9, 2017 05:41
-
-
Save martinyung/63feb9587feec6d77270973395e29fb4 to your computer and use it in GitHub Desktop.
[blogging purpose] grails upload controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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