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

jsss

v0.0.41

Published

Amazon S3 Multipart upload wrapper

Downloads

11

Readme

JSss

Nodejs Amazon S3 Multipart upload module

Dependency Status

Requirements

Installation

Download and install dependencies

$ npm install

Usage

var MultiPart = require("./src/JSss.js")("ohByBucket","MyAccessKey","mySecret","folde/theFileName.zip");
//Register for end event
MultiPart.on("jsss-end",function () {
	console.log("end");	
});
//Register for error event
MultiPart.on("jsss-error",function (err) {
	console.log(err);
});
//Upload finished
MultiPart.on("jsss-upload-notice",function (partNumber,status,err) {
	if (status) {
		partFinished++;
		if (partFinished == partCount) {
			MultiPart.finishUpload();
		}
	}
	else {
		console.log("Upload finished with error:" + err);
		MultiPart.abortUpload();
	}
});
//Must be registered to MultiPart API start
MultiPart.on("jsss-ready",function () {
	console.log("ready");

	partFinished = 0;
	partCount = 2;
	//All datas need to be 5MB>
	MultiPart.uploadChunk("the big data",1);
	MultiPart.uploadChunk("the big data2",2);
});

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
  • options - **Type:**OptionObject - **Description:**Options Object - OPTIONAL
  • options.endPoint - **Type:**string - **Description:**End point to be used - Default is s3.amazonaws.com - OPTIONAL
  • options.useSSL - **Type:**boolean - **Description:**Use SSL or not - Default is true - OPTIONAL
  • options.dataIntegrityEnabled - **Type:**boolean - **Description:**Generates MD5 hash of uploading data for S3 integrity check - Default is true - OPTIONAL
  • options.rrsEnabled - **Type:**boolean - **Description:**Reduced redundancy storage enables customers to reduce their costs by storing non-critical, reproducible data at lower levels of redundancy than Amazon S3's standard storage. - Default is false (Higher level of redundancy) - OPTIONAL

Sample:

var MultiPart = require("./src/JSss.js")("myBucket","AWSAccessKey","AWSSecretAccessKey","fileNameToBeUp",{ endPoint:"secondary.s3.com",useSSL:false,dataIntegrityEnabled:false });

Upload Chunk

Notice this function will not call error listener, it will call upload-notice listener with positionChuck parameter and if succeeded or not, so you can try to re-upload that part if you want.

Parameters:

  • chunkData - **Type:**string || Buffer - **Description:**Chunk to be uploaded - REQUIRED
  • chunkPosition - **Type:**number - **Description:**Chunk Position, so you can upload multiple parts at same time - REQUIRED
  • fileEncoding - **Type:**number - **Description:**Which encoding to use when uploading. Default is utf8 - OPTIONAL

Sample:

MultiPart.uploadChunk(chunkData,chunkPosition,'binary');

Finish Upload

This method will finish upload, and can take a bit long for large files, since amazon will only answer the request when all parts are together.

Sample:

MultiPart.finishUpload();

Finish Upload

This method will cancel upload and delete all uploaded chunks.

Sample:

MultiPart.abortUpload();

Events

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

Event-String: jsss-ready

Sample:

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

####Upload Notice This event will be reached when an upload succeeded or failed.

Event-String: jsss-upload-notice

Sample:

MultiPart.on("jsss-upload-notice",function (partNumber,status,err) {
    if (status) {
       console.log("success :) on part:" + partNumber + " with etag:" + err);
    }else {
	   console.log("error:" + err + " on part:" + partNumber + "let's try again?");
    }
});

####Error This event will be reached when an error occur in any fundamental part of upload (start,finish,abort). Do NOT call terminate or abort method from error event, since those methods can emit an error event.

Event-String: jsss-error

Sample:

MultiPart.on("jsss-error",function (err) {
	console.log("Bad",err);
}

####End This event will be reached when upload finished by abortUpload() or finishUpload() OR if it didn't start properly.

Event-String: jsss-end

Sample:

MultiPart.on("jsss-end",function () {
	console.log("Bye");
}

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

MIT