No support for POSTing files?


#1

Hey, am I correct in saying that the Serverless Framework doesn’t support POSTing of files (like http://electron.atom.io/docs/api/crash-reporter/#crash-reporter-payload)? AWS Lambda doesn’t support it and I don’t remember seeing anything in your docs.


#2

AWS API GW (which provides the HTTP(S) interface to Lambda) supports POST requests.

You need to know the ins-and-outs of API GW to configure it properly, but there’s examples in the Serverless docs.


#3

@rowanu APIG doesn’t support file uploads though. The way you would do it is upload directly into S3 by requesting a short lived URL to upload into, then have Lambda functions react to it.


#4

Ah, my bad - I assumed POST support was enough, but haven’t done it myself.

A bit of research turns up this guide to proxy S3 via API GW which looks relevant.


#5

OK yeah that’s as I thought.


@flomotlik

@rowanu APIG doesn’t support file uploads though. The way you would do it is upload directly into S3 by requesting a short lived URL to upload into, then have Lambda functions react to it.

This wouldn’t work as the POST is not under my control (reminder: http://electron.atom.io/docs/api/crash-reporter/#crash-reporter-payload). I’d need something to catch this POST and upload to S3, then have Lambda react to that. It’s the same problem, kind of.


But since the first part of my question has been pretty much validated, does Serverless Framework support what I want to do at all? I.e. if I use a different provider like webtask.io.


#6

Oh wait… Serverless only supports AWS?

( https://serverless.com/framework/docs/#providers )


#7

For my case, I turn binary file into base64 code from client side and send it in JSON file along with other field that you want like file name. On the client side (lambda), turn the base64 code into binary format and put into the bucket by using putObject function.

This is how I turn base64 into binary -
let data = JSON.parse(event.body)
let binary = new Buffer(data[‘base64field’], ‘base64’)
s3.putObject({ Body: binary, …})

Cheers,
John