aws-s3
aws-s3 copied to clipboard
ReferenceError: FormData is not defined
I'm not sure why I get this when I do uploadFile
Where are you uploading the file from ?
From the IOS simulator gallery.
Tim
Sent from my iPhone
On Sep 28, 2018, at 8:17 AM, Faustino Kialungila [email protected] wrote:
Where are you uploading the file from ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I am getting this error also. Uploading from my local
I get the same error with NodeJS v10.13.0. It is because the NodeJS doesn't natively include the FormData class.
One should include this package: https://www.npmjs.com/package/form-data
And replace:
var r=new FormData
with:
var r=new require('form-data')
Or something similar...
getting the same error
This is a client-side library, it only works on the browser for the moment! But you can send a PR to support server-side uploading!
Getting the same error here
i getting same error and i am using graphql apollo server and client for the same kindly let me know solution for the same
This is a client-side library, it only works on the browser for the moment! But you can send a PR to support server-side uploading!
The README should say that. I lost an hour on this.
Why would you want to use a client side library for node when there an official sdk for node. Here is sample code you can use to upload files to AWS S3 using aws-sdk package:
const fs = require('fs')
const path = require('path')
const S3 = require('aws-sdk/clients/s3')
let file = '/path/to/your/file'
let s3 = new S3({
accessKeyId: 'your-access-key-id',
secretAccessKey: 'your-secret-key',
})
const config = {
Key: path.basename(file),
Bucket: 'your-bucket-name',
Body: fs.createReadStream(file),
}
s3.upload(config, function (err, data) {
console.log(err, data)
})
I am getting the same error, using material-ui-dropzone to fetch pdf files from reactjs, passing it to nodejs server and using aws-s3 to insert it into AWS S3.
I tried what @arashmilani recommended but it didn't work, can anyone help me? It will be a great help.
Thanks.