Hi,
I’m trying to get AwsS3 working with getUploadParameters in React + Node.js. I’m not sure what I am doing wrong, but I keep running into the error:
AwsS3: got incorrect result from 'getUploadParameters()' for file '24px.png', expected an object '{ url, method, fields, headers }'.
I have looked at this issue: https://github.com/transloadit/uppy/issues/819 but I still seem to be getting this error.
My front-end code:
Uppy()
.use(AwsS3, {
getUploadParameters(file) {
axios.get('/api/aws/signUrl/put', {
params: {
fileName: file.name,
contentType: file.type,
bucket: props.bucket,
directory: 'test'
}
})
.then((result) => {
console.log(result.data)
return {
url: result.data.url,
method: result.data.method,
fields: result.data.fields,
headers: {}
}
})
.catch((err) => {
console.log(err.response)
})
}
})
my back-end code:
router.get('/signUrl/put', function (req, res, next) {
console.log('hi')
const key = `${req.query.directory}/${shortid.generate()}` // for the chat, it will be the participant_id
s3.getSignedUrl('putObject', {
Bucket: req.query.bucket,
Key: key,
Expires: 180,
ContentType: req.query.contentType,
Metadata: {
fileName: req.query.fileName,
}
}, (err, url) => {
if (err) {
console.log(err)
res.status(500).json('Internal server error')
} else {
res.status(200).json({ url: url, key: key, method: 'put', fields: {} })
}
})
})
my console.log of my console.log(result.data)
looks good, but i still seem to be getting this error.
fields: {}
key: "test/9QJJEP0uy"
method: "put"
url: "https://mybucketname.s3.amazonaws.com/test/9QJJEP0uy?Content-Type=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MYCREDENTIALS&us-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190917T152817Z&X-Amz-Expires=180&X-Amz-Signature=SIGNATUREHERE&X-Amz-SignedHeaders=host%3Bx-amz-meta-filename&x-amz-meta-filename=24px.png"
Any help would be appreciated!
Thanks