benjreinhart / react-native-aws3

Pure JavaScript React Native library for uploading to AWS S3
MIT License
398 stars 151 forks source link

Unable to upload video when bucket name contains dots eg. domain names #90

Open tomasz-konecki opened 4 years ago

tomasz-konecki commented 4 years ago

Hi,

First of all, I would like to say that I appreciate your effort to create this library. After some time of using it in my react native application, I noticed that occasional problems occurred while uploading videos to the server. It turned out to be due to the structure of the url variable in the RNS3.js file.

I changed the original structure:

var url =
    "http://" +
    options.bucket +
    "." +
    (options.awsUrl || AWS_DEFAULT_S3_HOST);

to:

  var url = `https://s3.${options.region}.amazonaws.com/${options.bucket}/`;

and now it is working without any problems.