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

any-file

v0.0.30

Published

Node.js library to copy files between several storage sources (ftp, http, s3, ssh, local, ...)

Downloads

198

Readme

Any-File

Node.js library to copy files between several storage sources (ftp, http/https, s3, ssh, local, ...)

Getting Started

Please, follow next instructions to get a working copy of the project up and running on your local machine for development and testing purposes. This is an unstable release. Please, don't use in production environments.

Prerequisities

You need to install nodejs >= 5.8.0 on your machine:

sudo apt-get install nodejs

Probably, library will work with older nodejs versions.

Installing

Please, execute next command to install package

npm install any-file

After that, include the module in your code:

var AnyFile = require('any-file');

Running the tests

To run tests, please execute

make test

All test use public files shared on internet. So, you have to find no problems when testing.

Samples

This module allow to copy files between different storage systems.

All queries begin with calling function from to define source file to copy

from("protocol://username:password@server/path/to/file")

and define destination with method to

to("protocol://username:password@server/path/to/file", callback)

Next protocols are accepted by the library:

  • ftp
  • http, https (only download)
  • scp
  • s3
  • local file system

Additionally, if no protocol schema is defined, local system is assumed.

You can compress and uncompress your files in all operations. Next are supported compression formats: zip, gzip. Please, take in consideration that some zip files could have wrong headers. In those cases, file will be renamed to final extension only.

Next sources are accepted by the library:

You can copy ftp file to local file system

var af = new AnyFile();
var fromFile ="ftp://anonymous:miemail%[email protected]/100KB.zip";
var toFile = "100KB.zip";
af.from(fromFile).to(toFile, function(err, res) {
	if (res) {
		console.log("File copied!");
	} else {
		console.log("File not copied!");
	}
});

Or http file with needed auth to local file system

var af = new AnyFile();
var fromFile = "http://anonymous:miemail%[email protected]/100KB.zip";
var toFile = "100KB.zip";
af.from(fromFile).to(toFile, function(err, res) {
	if (res) {
		console.log("File copied!");
	} else {
		console.log("File not copied!");
	}
});

Or copy from sftp to s3

var af = new AnyFile();
var fromFile = "sftp://demo:[email protected]:/readme.txt";
var toFile = "s3://AKIAIZHM3T2QFIRSVQ5A:[email protected]/any-file-us/readme.txt";
af.from(fromFile).to(toFile, function(err, res) {
	if (res) {
		console.log("File copied!");
	} else {
		console.log("File not copied!");
	}
});

Or copy from sftp to s3 gzipped file

var af = new AnyFile();
var fromFile = "sftp://demo:[email protected]:/readme.txt";
var toFile = "s3://AKIAIZHM3T2QFIRSVQ5A:[email protected]/any-file-us/readme.txt.gz";
af.from(fromFile).to(toFile, function(err, res) {
	if (res) {
		console.log("File copied!");
	} else {
		console.log("File not copied!");
	}
});

You can find more code samples on samples folder using accepted protocols (http, ftp, s3, scp and local). Please, check it out.

Debugging

You can debug the library this way

DEBUG=app node youfile.js

This will show debugging messages on console.

Todo

On future releases, next features will be added:

  • events (start, progress, end, error) instead of callbacks

Contributions

Please, feel free to send pull requests or comments to the project. Contributions are welcome!

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Miquel Colomer - Initial work - mcolomer

See also the list of contributors who participated in this project.

Who is using this repo?

Please, let me know if you are using this repository in a production environment. Next sites use this module:

  • uProc - Data quality service with a huge catalog to Normalize, Validate, Enrich and Deduplicate your data

License

This project is licensed under the Apache License - see the LICENSE file for details