Is it possible to pass JavaScript File Object from browser to AWS Lambda through API Gateway (finally to S3). I am using TypeScript and React.
Environment
Frontend
- TypeScript
- React
- AWS Amplify (to use API module)
Backend(AWS Lambda)
- Node.js
What's expected
to pass File Object, which got from browser by <input type='file'>, to backend aws lambda through API Gateway.
What's happening
console.log(event) at backend, the log output was empty.
What I want to know
the way how to pass File Object(Blob) to lambda correctly. (Just a link to document, it'll also really help me.)
Code (Frontend)
import { API } from 'aws-amplify'
...
const file = { body: this.state.file }
console.log(file) // output was collect File Object at this time
API.post(<API_NAME>, <PATH>, file)
.then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
Code (Backend)
exports.lambdaHandler = function (event, context, callback) {
console.info(`event.body: ${event.body}`) // got `event.body: {}` at Cloud Watch Logs
...
}
Is it possible what I'm trying to do by setting Content-Type or something? (I couldn't find any documentation. I've been started programming just only for one year).