Search code examples
reactjsgoogle-cloud-storagechunksvideo-uploadsigned-url

Google Resumable Upload


I want to implement a google resumable upload for a video recording i am doing from my web app. I am fetching a signed url and initiating the resumable upload immediately when the first chunk is available. Here the issue I am facing is that the chunks will be available in the bucket only after i send my final chunk which ends with a 200 status. but my requirement is that each chunk will be immediately available so that my Backend can start some processing immediately as the first chunk is available. Can some help me in how to achieve this in my react app using google cloud storage?


Solution

  • There is a strong consistency in the item uploads to Google Cloud Storage. This implies that until the object has been fully uploaded and all chores related to Cloud Storage, including replication, is completed, it will not be visible. Until the upload is finished and your software/tool gets a success response, you cannot see or access an object.

    It is already stated in the document that : Only a completed resumable upload appears in your bucket. So you cannot access each chunk before uploads are completed.

    Alternatively, you can check this article which is using react as frontend and node.js as backend. You can use the resumable upload concept where Chunks are uploaded sequentially, enhancing stability. And In the Backend endpoint will receive and process file chunks sequentially using the multer package. Upon receiving the last chunk, it merges chunks into a complete file .

    For your use case may be you can modify the code from the article accordingly to do required activity when first chunk is completed.