npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cloud-pipe

v0.0.131

Published

Simple Buffer that automatically upload it data to S3.

Downloads

6

Readme

CloudPipe

Simple Buffer that automatically upload it data to S3 on chunks.

About

Cloud-Pipe is an easy way of handling huge datas in very low memory and ephemeral writeable filesystems.
It can receive data and buffer it to some size specified by you, after fill buffer up, it'll stop receiving data and uploading it to S3 with MultipartUpload. This allows you to upload multiple chunks into S3 and join then later on cloud.

Requirements

Installation

Download and install dependencies

$ npm install

Usage

var maxChunkSize = 10000000; //10 mb
var cp = require("./../src/cloud-pipe.js")("my bucket name","myAccessKey","mySecret","file.zip",maxChunkSize);
cp.on("cp-error",function (err) {
	console.log("error",err);
});
cp.on("cp-end",function () {
	console.log("end");
});
cp.on("cp-drained",function () {
	console.log("should resume writing");
});
//Must be registered in order to CloudPipe get ready
cp.on("cp-ready",function () {
	var chunk = "OMG"
    if (!cp.write(chunk)) { /*wait until cp-drained event, and write again there*/ }
    else { cp.finish(); }
});

More samples at samples/ directory.

Methods

Initialize Wrapper

Parameters:

  • bucketID - **Type:**string - **Description:**Name of Object in S3 bucket - REQUIRED
  • AWSAccessKeyID - **Type:**string - **Description:**AWS AccessKeyID - REQUIRED
  • AWSSecretAccessKey - **Type:**string - **Description:**AWS SecretAccessKey - REQUIRED
  • fileName - **Type:**string - **Description:**fileName to be on S3 - REQUIRED
  • chunkSize - **Type:**integer - **Description:**Chunk in bytes to be on S3 (Got be 5MB or bigger) - REQUIRED
  • options - **Type:**OptionObject - **Description:**Options Object - OPTIONAL
  • options.endPoint - **Type:**string - **Description:**End point to be used, default s3.amazonaws.com - OPTIONAL
  • options.useSSL - **Type:**boolean - **Description:**Use SSL or not, default is true - OPTIONAL
  • options.maxRetry - **Type:**integer - **Description:**Max upload retry, 0 will disable retries. Default is 3 - OPTIONAL

Sample:

var CloudPipe = require("cloud-pipe")("myBucket","AWSAccessKey","AWSSecretAccessKey","fileNameToBeUp",10000000,{ endPoint:"secondary.s3.com",useSSL:false,maxRetry:1 });

Write Chunk

This function will not call error listener, it'll return false if cannot write chunk size.
After it'll fire cp-drained event when can write again.

Parameters:

  • chunkData - **Type:**String - **Description:**Chunk to be on buffer and after uploaded to S3. - REQUIRED

Sample:

CloudPipe.write('OMG This is my chunk');

Finish Upload

This method will finish upload and upload what remains on Buffer. It can take a bit long for large files, since amazon will only answer the request when all parts are joined.

Sample:

CloudPipe.finish();

Abort Upload

This method will cancel upload, and delete all uploaded chunks.

Sample:

CloudPipe.abort();

Events

####Ready This event MUST be registered in order to wrapper start. When this event is reached you are able to start writing.

Event-String: cp-ready

Sample:

//Must be registered to CloudPipe API start
cp.on("cp-ready",function () {
	console.log("I'm ready :)");
}

####Drained Notice This event will be reached when old buffer has been uploaded with success, so you can start writing again.
By default if error happen it will try 3 times until emit error event, this can be set on initialization options.

Event-String: cp-drained

Sample:

cp.on("cp-drained",function () {
	console.log("resuming cpipe write");
	cp.write("resume data");
});

####Error This event will be reached when an error occur in any part that cannot be recovered, so you need to try again. :(
Do NOT call terminate or abort method from error event, since those methods can emit an error event.

Event-String: cp-error

Sample:

cp.on("cp-error",function (err) {
    console.log("error in cpipe",err);
});

####End This event will be reached after finished by abort() or finish() OR if it didn't start properly.

Event-String: cp-end

Sample:

cp.on("cp-end",function () {
	console.log("Bye cpipe");
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

GPL v3