New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

filesource-https

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesource-https

Takes either a web-url, filepath, or raw data and returns given data as a filepath, or raw data

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

filesource.js

Install: npm install fileosurce

You can e.g. use it, if you want to offer a function, taking all possible types of data sources.

Here are some simple examples how to use it:

var filesource = require('filesource');

// Converts web-source to raw data
filesource.getRawData("http://blabla.com/blabla.pdf", function(resp){
	if(!resp.success)
	{
		console.log("Sth. went wrong: " + resp.error);
		return;
	}
	
	console.log(resp.data);	// raw data
});

// Converts filepath to raw data
filesource.getRawData("/files/example.pdf", function(resp){
	if(!resp.success)
	{
		console.log("Sth. went wrong: " + resp.error);
		return;
	}
	
	console.log(resp.data);	// raw data
});

// Converts web-source to readable filepath
filesource.getDataPath("http://blabla.com/blabla.pdf", function(resp){
	if(!resp.success)
	{
		console.log("Sth. went wrong: " + resp.error);
		return;
	}
	
	console.log(resp.data);	// local filepath
	
	resp.clean();
});

// Converts raw data to readable filepath
var rawData = fs.readFileSync("/files/example.pdf");

filesource.getDataPath(rawData, function(resp){
	if(!resp.success)
	{
		console.log("Sth. went wrong: " + resp.error);
		return;
	}
	
	console.log(resp.data);	// local filepath
	
	resp.clean();
});

FAQs

Package last updated on 03 Feb 2018

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