Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gcs-resumable-upload

Package Overview
Dependencies
Maintainers
6
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gcs-resumable-upload

Upload a file to Google Cloud Storage with built-in resumable behavior

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
258K
decreased by-1.04%
Maintainers
6
Weekly downloads
 
Created

What is gcs-resumable-upload?

The gcs-resumable-upload npm package is designed to facilitate resumable uploads to Google Cloud Storage. It allows users to upload large files in chunks, which can be particularly useful for handling network interruptions and ensuring that uploads can be resumed from the point of failure.

What are gcs-resumable-upload's main functionalities?

Initiate a Resumable Upload

This feature allows you to initiate a resumable upload session by creating a unique upload URI. This URI can be used to upload the file in chunks.

const { Upload } = require('gcs-resumable-upload');
const upload = new Upload({
  bucket: 'my-bucket',
  file: 'my-file.txt',
  authConfig: 'path/to/keyfile.json'
});

upload.createURI((err, uri) => {
  if (err) {
    console.error('Error creating URI:', err);
  } else {
    console.log('Upload URI:', uri);
  }
});

Upload a File Chunk

This feature allows you to upload a file chunk to the previously created upload URI. It handles the actual data transfer to Google Cloud Storage.

const fs = require('fs');
const { Upload } = require('gcs-resumable-upload');
const upload = new Upload({
  bucket: 'my-bucket',
  file: 'my-file.txt',
  authConfig: 'path/to/keyfile.json'
});

const uri = 'your-upload-uri';
const fileStream = fs.createReadStream('path/to/local/file');

upload.startUploading(uri, fileStream, (err, res) => {
  if (err) {
    console.error('Error uploading file:', err);
  } else {
    console.log('File uploaded successfully:', res);
  }
});

Resume an Interrupted Upload

This feature allows you to resume an interrupted upload by continuing from the last successfully uploaded chunk. It ensures that the upload process can be completed even after a network failure.

const fs = require('fs');
const { Upload } = require('gcs-resumable-upload');
const upload = new Upload({
  bucket: 'my-bucket',
  file: 'my-file.txt',
  authConfig: 'path/to/keyfile.json'
});

const uri = 'your-upload-uri';
const fileStream = fs.createReadStream('path/to/local/file');

upload.continueUploading(uri, fileStream, (err, res) => {
  if (err) {
    console.error('Error resuming upload:', err);
  } else {
    console.log('Upload resumed successfully:', res);
  }
});

Other packages similar to gcs-resumable-upload

Keywords

FAQs

Package last updated on 10 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc