Aws S3 getUploadParameters help

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

It seems to be my back-end aws-sdk function, since the URL that is generated keeps giving me the error:

The request signature we calculated does not match the signature you provided. Check your key and signing method.

In your first snippet, the result of axios.get() was not being returned from getUploadParameters(), so Uppy instead saw undefined. Changing it to return axios.get()... should fix that problem.

Given your second post, I assume you did so already? :smiley:

If so I’m not sure what would cause that second error yet … the signing code looks right to me, unfortunately AWS doesn’t give a lot of detail in this type of error message :confused: