0

Trying to use a presigned-url for aws but I keep getting the error when I try to upload a photo:

[Uppy] [15:26:41] Failed to upload buffalo1.jpg AwsS3: got incorrect result from 'getUploadParameters()' for file 'buffalo1.jpg', expected an object '{ url, method, fields, headers }' but got 'undefined' instead.

I have everything set up just as the documentation advises. Can anyone take a look and tell me what it is that I might be missing?

const uppy = useUppy(() => {
return new Uppy({ autoProceed: true }).use(AwsS3, {
  getUploadParameters(file) {
    return fetch(
      `${process.env.baseUrl}/api/asset/presign/upload?assetId=${props.asset.id}&key=${file.id}&contentType=${file.type}`
    )
    .then((res) => {
      return res.json()
    })
    .then((data) => {
      return {
        method: data.method, //data.method,
        url: data.url,
        fields: {},
        headers: {
          "Content-Type": file.type,
        },
      };
    })
    .catch((err) => {
      console.log("error: ", err);
    });
  },
});

});

12jikan
  • 23
  • 6
  • Get some console.logging at the beginning of each of your .then blocks to make sure they are being executed. Also did your console.log with an error get printed? Also, check the network tab to make sure the request/response on that fetch was as expected. – Stephen Crosby Sep 29 '21 at 22:38
  • Is the URL in the `fetch` call correct? Try logging that out to the console to make sure. – juliomalves Sep 30 '21 at 14:50

0 Answers0