0

Re-question

environment : swift, Nodejs, s3, lambda, aws-serverless-express module

  1. Problem:

After uploading AS multipart Format with Alamofire(multipart/form-data) on swift, The image is broken on the s3 in AWS

code:

let photoKey = value.originalname + insertedReviewId + `_${i}.jpeg`
let photoParam = {
    Bucket: bucket,
    Key: photoKey,
    Body: value.buffer,
    ACL: "public-read-write",
    ContentType: value.mimetype, /* minetype: image/jpege */
};

//image upload 
let resultUploadS3 = await s3.upload(photoParam).promise();

Thanks to read

XOneto9
  • 15
  • 7
  • 1
    "the code set up on lambda with api-gateway has error" what error? "the preview image is not load" where? – nickolay.laptev Dec 26 '19 at 21:09
  • 1
    @nickolay.laptev oh.. sorry not much information. Yes, the process is complete but, the preview or download to s3 is not load just I got a message like " this file is broken" – XOneto9 Dec 27 '19 at 16:22
  • 1
    Your question is very difficult to understand. Please try to reduce it to a simple example that shows the problem. Also, as a general rule, you should not assign an ACL of public-read-write to an S3 object - there is almost never a good reason to do this. – jarmod Dec 27 '19 at 16:30
  • 1
    @jarmod oh, sorry. ok I will change all of it to simply questions. – XOneto9 Dec 28 '19 at 16:27

1 Answers1

0

Self answer

I use aws-serverless-express and for middleware, aws-serverless-express/middleware.

I don't know what is problem, however, I remove aws-serverless-express/middleware module it is work. all of image perfectly upload, not broken file.

if you use aws-serverless-express/middleware, body-parser, multer on Nodejs, let try remove aws-serverless-express/middleware.

XOneto9
  • 15
  • 7
  • 1
    My solution: https://stackoverflow.com/questions/61003311/serverless-i-image-upload-to-s3-broken-after-deploy-local-worked-only – Binh Ho Apr 03 '20 at 01:01