Home > Back-end >  Resumable and Validation on createWriteStream Node.js
Resumable and Validation on createWriteStream Node.js

Time:11-23

I've been using Google cloud storage api to upload some files. I've run into some errors of socket hang up when using the request for the upload.

After searching a bit, I've came across Error: socket hang up code: 'ECONNRESET' on Google cloud storage which solved the issue using:

.createWriteStream({
      resumable: false,
      validation: false,
       ...
    }

I couldn't find any documentation about those parameters (resumable and validation) and why using them solved my issue. How those parameters works on this context?

CodePudding user response:

According to the reference for the Cloud Storage API for Node, the resumable property is used to force a resumable upload. Resumable uploads are helpful to bypass connection errors when uploading objects to Cloud Storage buckets. In this context, the resumable property appears useful, since ECONNRESET errors include connection timeouts. As for the validate property, it is used to perform checksum validations.

I also noticed that the thread you linked does not use the provided upload method of the API, which, as per the docs, is a wrapper for File.CreateWriteStream() and is the method used to upload files as per the documentation and related threads.

  • Related