Unable to successfully upload to Google Cloud with a signed url

Viewed 157

Was hoping to get some insight to see what I might be missing since I'm noticing the video I'm trying to upload isn't working.

I first get a signedURL that connects to my bucket successfully. I then

  const submitVideo = async () => {
    const url = await getSignedUrl({
      variables: { filename: "google.jpeg" }
    }).then(async response => {
      if (response.data && response.data.getSignedUrl) {
        const url = response.data.getSignedUrl.url;
        const pathUrl = url.split('?');
        const videoPath = pathUrl[0];
        
        const uploadedReponse = await uploadToGoogleCloud(url);
      }
    });
  }

  const uploadToGoogleCloud = async (url) => {
    const videoFile = await fetch(video.uri);
    const blob = await videoFile.blob();
    const response = await fetch(url, {
      method: 'PUT',
      body: blob,
    }).then(res => console.log("thres is ", res)).catch(e => console.log(e));
  }

When I worked with AWS. Doing this worked without an issue.

    const type = video.split('.').pop();
    const videoFile = await fetch(video);
    const blob = await videoFile.blob();
    const response = await fetch(uri, {
        method: 'PUT',
        body: blob,
        headers: {
            'Content-Type': type,
            'x-amz-acl': 'public-read'
        }
    }).catch((e) => console.log('THE ERROR FOR VIDEO UPLOAD IS ', e));

Is it because I am missing Content-Type and x-amz-acl? I'm not seeing any error appear which is why I was hoping to get some insight. Thank you in advance.

1 Answers

Found the problem that I was having. I was submitting in my getSignedUrl request with the wrong content-type. Since I am currently using an IOS phone, the videos being retrieved are .mov. This within google states it to be 'video/quicktime'.

This type information can be referenced at https://help.encoding.com/knowledge-base/article/correct-mime-types-for-serving-video-files/

Hope this helps anyone who might get stuck in wondering why a video isn't being pushed to their bucket

Related