In AWS environment I want to upload a file to S3 via API gateway. I can't use lambda, because the 6MB payload limit. (The API gateway's 10MB limit is fine.) I could manage to upload a file with POST request and binary body. My question is how can I upload a picture which is wrapped in a multipart/form-data and can I set a file size and format limitation without using lambda functions?
You should use aws-sdk to create the API end point and get the url:
API Code(aws-sdk API Doc) :
s3.getSignedUrl('putObject')
S3.putObject
for upload document, it is a difference concept return new Promise((resolve, reject) => { let url = this.S3.getSignedUrl("getObject", { Bucket: bucket, Key: key, Expires: expires_second }) return resolve(url)
S3 Bucket Config (Reference Link) :
[ { "AllowedHeaders": [ "*", "Authorization" ], "AllowedMethods": [ "POST", "GET", "PUT", "DELETE", "HEAD" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [], "MaxAgeSeconds": 3000 } ]
AllowedMethods
existing PUT
methodUpload Document(Postman case)
s3.getSignedUrl('putObject')
{ Accept: '*/*'}
{Accept: 'image/png' }
now you may check the s3 bucket
other helpful reference : https://medium.com/@aidan.hallett/securing-aws-s3-uploads-using-presigned-urls-aa821c13ae8d
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.