Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Failed to upload file directly to S3 with react-native-background-upload

I tried to upload a file with react-native-background-upload, but my order of parameters is not as required. How can I fix it? Seem I can't change the order of my request.

Here is my code

  const fileInfo = await Upload.getFileInfo(path);
  const options: any = {
    url: url,
    path: path,
    method: 'POST',
    type: 'multipart',
    field: 'file',
    maxRetries: 2, // set retry count (Android only). Default 2
    headers: {
      'content-type': fileInfo.mimeType, // server requires a content-type header
      'content-length': `${fileInfo.size}`,
    },
    parameters: {
      key: `${fields.key}/${fileInfo.name}`,
      acl: fields['acl'],
      bucket: fields['bucket'],
      'X-Amz-Algorithm': fields['X-Amz-Algorithm'],
      'X-Amz-Credential': fields['X-Amz-Credential'],
      'X-Amz-Date': fields['X-Amz-Date'],
      'X-Amz-Signature': fields['X-Amz-Signature'],
      Policy: fields['Policy'],
      'Content-Type': fileInfo.mimeType,
    },
    notification: {
      enabled: true,
    },
    useUtf8Charset: true,
  };

  Upload.startUpload(options)
    .then(uploadId => {
      console.log('Upload started');
      Upload.addListener('progress', uploadId, data => {
        console.log(`Progress: ${data.progress}%`);
      });
      Upload.addListener('error', uploadId, data => {
        console.log(`Error: ${data.error}%`);
      });
      Upload.addListener('cancelled', uploadId, data => {
        console.log('Cancelled!', data);
      });
      Upload.addListener('completed', uploadId, data => {
        // data includes responseCode: number and responseBody: Object
        console.log('Completed!', data);
      });
    })
    .catch(err => {
      console.log('Upload error!', err);
    });

This is the error message from s3

It requires key as the first parameter

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>InvalidArgument</Code>
  <Message>Bucket POST must contain a field named 'key'.  If it is specified, please check the order of the fields.</Message>
  <ArgumentName>key</ArgumentName>
  <ArgumentValue></ArgumentValue>
</Error>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!