Возможно, этот фрагмент кода может помочь некоторым людям, у которых возникают проблемы с загрузкой по предварительно подписанному URL-адресу S3 с помощью React Native.

Мой компонент загрузчика S3PresignedUrl (он использует тип потока):

/**
 *
 * @flow
 */
'use strict';
class S3PresignedUrl {
sendFile(presignedurl: string,
    file: {uri: string, type: string, name: string},
    onSuccess: () => void,
    onFail: () => void,
    onProgress: () => void) {
    // from http://blog.rudikovac.com/react-native-upload-any-file-to-s3-with-a-presigned-url/
    const xhr = new XMLHttpRequest();
    xhr.upload.addEventListener('progress', (e) => {
      // handle notifications about upload progress: e.loaded / e.total
      console.log('progress');
      console.log(e);
      onProgress(e);
    }, false);
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
        if (xhr.status === 200) {
          // Successfully uploaded the file.
          console.log('successfully uploaded presignedurl');
          console.log(xhr);
          onSuccess(file.uri);
        } else {
          // The file could not be uploaded.
          console.log('failed to upload presignedurl');
          console.log(xhr);
          onFail(file.uri);
        }
      }
    };
    xhr.open('PUT', presignedurl);
    xhr.setRequestHeader('X-Amz-ACL', 'public-read');
    // for text file: text/plain, for binary file: application/octet-stream
    xhr.setRequestHeader('Content-Type', file.type);
    xhr.send(file);
  }
}
export { S3PresignedUrl };

Вот мой скрипт nodejs для генерации моего presignedurl (он включает создание schemeurl, которое вы можете проигнорировать в конце). В настоящее время это, вероятно, одна из самых полезных частей этого сообщения в блоге (остальное можно найти в Google), поскольку тип контента для аудио и видео является правильным для iOS - без этих точных типов контента S3 не справился с сообщение об ошибке не очень явное:

var aws = require('aws-sdk');
aws.config.region = 'us-west-2';
const s3 = new aws.S3();
const filename = 'video.mov'; // whatever you want to be saved in your S3 bucket.
const type = 'video'; //video or audio (for poodll recorder schemeurl)
const contenttype = 'video/quicktime';
//const contenttype = 'application/octet-stream'; // audio content type
const timelimit = 100;
const s3Params = {
Bucket: 'elasticbeanstalk-us-west-2-01326',
Key: filename,
ContentType: contenttype,
Expires: 600000,
ACL: 'public-read'
};
var signedurl = s3.getSignedUrl('putObject', s3Params);
console.log(signedurl);
// Here is the schemeurl url link for the Poodll Recorder.
console.log('poodllrecorder://?timelimit='+timelimit+'&type='+type+'&presignedurl='+encodeURIComponent(signedurl));

Примечание: вам также необходимо настроить разрешение вашего сегмента S3, чтобы разрешить PUT, см. Https://devcenter.heroku.com/articles/s3-upload-node#initial-setup

Большое спасибо: