Uploading videos to server

Hi I have an app where I am trying to upload a video from a phone to a server.

For some reason on Iphones, sometimes when a video is uploaded it is just uploaded as an image. My team and I been stuck on this issue for over 2 weeks.

Can anyone please help shed some light on this?

Thank you

1 Like

Hey @jaequery,

Where are you uploading the files to? Also, how are you currently sending them to the server? It’s hard to shed any light without any information.

A quick thought is that this may be of help to you: Uploading results as empty file without mime type without errors · Issue #13 · expo/firebase-storage-upload-example · GitHub

Cheers,

Adam

1 Like

I am currently uploading files to a Ruby/Nginx server, which then uploads to S3.
this is the code to handle uploading images:

export const uploadMultipleImages = async (pt, onUploadProgress = null) => {
  let photos = cloneDeep(pt);
  for (let i = 0; i < photos.length; i++) {
    const onProgress = onUploadProgress ?
      event => {
        const progress = Math.floor((event.loaded / event.total) * 100);
        onUploadProgress(i, progress);
      } : () => {};
    let photo = photos[i];
    const mime = photo.type && isVideo(photo.type) ? 'video' : 'image';

    if (Platform.OS === "android") {
      // TODO: Need a better way to get file type on Android
      // This way don't work with mkv (which mime is video/x-matroska)
      const fileType = getFileTypeFromMime(photo.type);

      const fileUri = `${FileSystem.documentDirectory}${new Date()}.${fileType}`;
      await FileSystem.copyAsync({from: photo.file, to: fileUri});
      photos[i].uploadedUrl = await upload({uri: fileUri, onProgress, mime});
    } else {
      photos[i].uploadedUrl = await upload({uri: photo.file, onProgress, mime});
    }
  }

  return photos;
};

does this help? thanks.

Hi @adamjnav, our app’s using FormData to upload videos. It worked fine on Android but not on IOS. I tried multiple types of video and only mov video worked. Other common types like mp4, m4v were uploaded as a snapshot (an image) instead of the whole video

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.