0

I am successfully generating a presigned url to upload an image file to s3, but when I try and send the file I get a 400 error. Here is my front-end code.

const params = {
       name: fileName,
       mime: fileType,
       body: document.getElementById(fileattach).files[0],
       }

const resp = await axios.post(
       // running this in serverless-offline
      'http://localhost:3001/dev/image-upload',
      { name: fileName, mime: fileType }
)
const { uploadURL } = resp.data
console.log(uploadURL)

try {
   const resp1 = await axios.put(uploadURL, params, {
      headers: {
        'Content-Type': fileType,
      },
   })
   console.log(resp1)
} catch (e) {
   console.error(e)
}

I would be really grateful for any thoughts.

EDIT: The error reads The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

Nick Wild
  • 395
  • 1
  • 6
  • 18

0 Answers0