Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading files #157

Open
rama41222 opened this issue Jul 27, 2020 · 4 comments
Open

Uploading files #157

rama41222 opened this issue Jul 27, 2020 · 4 comments

Comments

@rama41222
Copy link

How to I handle files / multipart form data using lambda-api ?

  • I tried using multer and multer-s3 but it didn't work, I got req.pipe not found error
@sebastianDejoy
Copy link

yes please, busboy is limited...multer rules on NodeJS. Please add support to that.

@sebastianDejoy
Copy link

Any insight about piping on this framework?

@alejuanito
Copy link

Hi, were you able to process a multipart / form-data file? is it possible to do it with this library?

@sebastianDejoy
Copy link

sebastianDejoy commented Mar 4, 2021

Hey @alejuanito, yeap i was. The best approach is to use presigned urls that have a reasonable payload limit (50GB) as opposed to lambda/APIGW that is around 6MB.

I enabled an endpoint that return a presigned url:

const AWS = require('aws-sdk')

const s3 = new AWS.S3()
AWS.config.update({accessKeyId: 'id-omitted', secretAccessKey: 'key-omitted'})

// Tried with and without this. Since s3 is not region-specific, I don't
// think it should be necessary.
// AWS.config.update({region: 'us-west-2'})

const myBucket = 'bucket-name'
const myKey = 'test.pdf'
const signedUrlExpireSeconds = 3600;

const url = s3.getSignedUrl('getObject', {
    Bucket: myBucket,
    Key: myKey,
    Expires: signedUrlExpireSeconds
})

return url; //return this url as a value in your lambda response.

Then your API consumers (mobile aps) can upload whatever file they want through that presigned url:
curl -v --upload-file ${fileName} ${presigned_url}

Make sure to grant access from your S3 bucket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants