1

we are using react dropzone uploader to upload video to s3 uisng presigned URL.

Below is the code:-

const MyUploader = () => {

 
  const [snackBarOpen, setSnackBarOpen] = React.useState(false);
  const [snackbarTitle, setSnackbarTitle] = React.useState("");


    const handleClose = (event, reason) => {
        if (reason === "onclick") {
            return;
        }
        setSnackBarOpen(false);
        }
 
   
   const getUploadParams = async ({ meta: { name } }) => {
  const { fields, uploadUrl, fileUrl } = await getPresignedUploadParams(name)
  console.log(fields, uploadUrl, fileUrl)
  return { fields, meta: { fileUrl }, url: uploadUrl }
   }
  
 
  // called every time a file's `status` changes
  const handleChangeStatus = ({ meta, file }, status) =>
       
      
       
        {
          console.log(status)
          if(status == "done") {
           
            setSnackbarTitle("File uploaded Successfuly")
            setSnackBarOpen(true)
            window.location.reload(false);
          }
          else if (status == "error_upload") {
             setSnackbarTitle("error!!Please check")
             setSnackBarOpen(true)
         
          }
          else if (status == "uploading") {
             setSnackbarTitle("Uploading..Please wait don't close or refresh")
             setSnackBarOpen(true)
          }
          else {
             setSnackbarTitle(status)
             setSnackBarOpen(true)
          }
       
       
       
        }

  return (
    <div>
    <Dropzone
       getUploadParams={getUploadParams}
      onChangeStatus={handleChangeStatus}
      accept="video/*"
    />
    <SnackBar
                open={snackBarOpen}
                close={handleClose}
                snackbarTitle={snackbarTitle}
            />
   </div>       
  )
}

we are getting below error we try to find to find similar question in SO and found The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

As per above post have set signature version and region_name in backend.

<Error
>
<Code
>
InvalidRequest
</Code
>
<Message
>
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
</Message
>
<RequestId
>
5AZHFFW9Y080TTV5
</RequestId
>
<HostId
>
DzzSjYtIP73RoKN/UrNX5hgCOxJIMfwfE9HAuRlZrLKmK82n+ssBdf6jMUfbNXp4znfOX3LfrMU=
</HostId
>
</Error>

we have set signature version in backend.

client = boto3.client(
    's3',
    aws_access_key_id=Settings().AWSAccessKeyId,
    aws_secret_access_key=Settings().AWSSecretKey,
    config=Config(signature_version='s3v4'),
    region_name="ap-south-1"
)

It could be great if we can get help to resolve this.

Deepthi N
  • 11
  • 1

0 Answers0