Last active
May 6, 2018 09:53
-
-
Save stevepeak/2e74882710311c719e465777307086c6 to your computer and use it in GitHub Desktop.
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
### | |
Accept user uploads and store them in AWS S3 | |
### | |
http-endpoint method:'post' url:'/upload' as request, response | |
uploadedFile = request.files['myImageName'] | |
if uploadedFile is null | |
response finish message:"No file uploaded." code:400 | |
end story | |
if (uploadedFile size) > 3072 | |
response finish message:"File to large, must be less than 3MB." code:400 | |
end story | |
result = machinebox/nudebox image:uploadedFile | |
if result.found_nudity | |
response finish message:"File contains nudity, please try another." code:400 | |
end story | |
id = uuid new | |
uploadTo = '/uploads/{{id}}.png' | |
request finish message:'Will upload to {{uploadTo}}' code:201 | |
imagemagick convert file:uploadedFile resize:'64x64' | |
aws/s3 cp path:uploadedFile dest:uploadTo bucket:'myUploadBucket' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment