benjreinhart / react-native-aws3

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

video is 0 seconds long #30

Closed trops closed 7 years ago

trops commented 7 years ago

Not sure if I am doing something wrong here, but I have a recorded video, I can preview it perfectly, and then when I use the uploader it uploads fine, but the video that got uploaded to S3 doesn't playback properly. It is 0 seconds and only shows the first frame of the video. I am testing this on iOS first before testing on Android. Any ideas about this? I am using "video/quicktime" as the type and an assets-library uri that I use to preview the video and that is working.

benjreinhart commented 7 years ago

Although I feel like this should work, I have never tested video uploads. The only uploads I've tested myself are images. Perhaps someone else has experience with uploading files that are something other than jpg/png images?

trops commented 7 years ago

It totally works, it was something on my end. Uploading videos to s3 and had a permission issue :-)

John P. Giatropoulos Founder and CEO, swingbot.com http://www.swingbot.com

On Mar 1, 2017, at 4:23 PM, Ben Reinhart notifications@github.com wrote:

Although I feel like this should work, I have never tested video uploads. The only uploads I've tested myself are images. Perhaps someone else has experience with uploading files that are something other than jpg/png images?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

benjreinhart commented 7 years ago

Cool, I'm going to close this then.

trops commented 7 years ago

eh, spoke to soon man, it appears that it is uploading the file, but it wont play for some reason. Im uploading 2-3 second clips to test and the file size is 1.8MB or around there, but the video is 0 seconds. corrupt somehow. Im trying to work through it to see if something is fishy on my end...

Ill post some code for you in a moment.

trops commented 7 years ago

So here is the sample code I have for the upload for iOS....Ill have to change the filetype for android but just trying iOS for now...

uploadVideo() {
    const file = {
      uri: this.props.video.path,
      name: 'react-test-1.mov',
      type: 'video/quicktime'
    };
    let prefixPlatform = 'droid_';
    if (Platform.OS === 'ios') {
      prefixPlatform = 'ios_';
    }
    const options = {
      keyPrefix: prefixPlatform,
      bucket: 'uploads',
      region: 'us-east-1',
      accessKey: '<my_key>',
      secretKey: '<my_secret>',
      successActionStatus: 201
    };
    RNS3.put(file, options)
    .then(response => {
      if (response.status !== 201) {
        console.log('error uploading to S3');
      } else {
        console.log(response.body);
      }
    })
    .progress((e) => {
      console.log(e.loaded / e.total);
        this.updateProgress((e.loaded / e.total));
      }
    )
    .catch((err) => {
      console.log(err);
    });
  }

The progress updates in the console, and all looks well, but I get some sort of corruption in the video.

KristoferEng commented 7 years ago

I have the same issue. Did you ever figure out a fix?

trops commented 7 years ago

I ended up using another library react-native-fetch-blob I think. It allows you to grab the actual data of the asset. I looked at the code and basically iOS will grab the image always (despite being a video) so there needs to be code where it gets the asset that checks to see what type of file it is. If image all good, if video, need the NSData so you can do a multipart upload or handle it how you like.

I wish I could help but I'm not that familiar with android.

This library is great and just wish it had that video support :-)

On Mar 14, 2017, at 3:38 PM, Kristofer Eng notifications@github.com wrote:

I have the same issue. Did you ever figure out a fix?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dbrill commented 7 years ago

How is this issue closed? Can we re-open this?

prameetc commented 5 years ago

In the type pass video/mov and not video/quicktime.