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

ipfs-api

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-api - npm Package Compare versions

Comparing version 0.0.1-2 to 0.0.2

46

index.js

@@ -5,4 +5,4 @@ var net = require('net');

var assert = require('assert');
var needle = require('needle');
var qs = require('querystring');
var request = require('request');
var Multipart = require('multipart-stream');

@@ -22,20 +22,24 @@ var package = JSON.parse(fs.readFileSync(__dirname + '/package.json'));

if(args) opts.arg = args;
var query = qs.stringify(opts);
var data = getFileArgs(files);
var uri = 'http://' + address + API_PATH + path + '?' + query;
needle.post(uri, data, {
multipart: files != null,
user_agent: '/node-'+package.name+'/'+package.version+'/'
return request.post({
uri: 'http://' + address + API_PATH + path,
qs: opts,
useQuerystring: true,
headers: {
'User-Agent': '/node-'+package.name+'/'+package.version+'/'
},
formData: getFileForm(files)
}, function(err, res, data) {
return cb(err, data);
try {
return cb(JSON.parse(err || 'null'), JSON.parse(data || 'null'));
} catch(e) {
return cb(err, data);
}
});
}
// TODO: build a multipart readable stream out of other readable streams
function getFileArgs(files) {
function getFileForm(files) {
if(!files) return null;
var output = {};
if(!Array.isArray(files)) files = [files];

@@ -49,4 +53,7 @@

output[i] = {
file: file,
content_type: 'application/octet-stream'
value: fs.createReadStream(file),
options: {
contentType: 'application/octet-stream',
filename: file
}
};

@@ -56,4 +63,7 @@

output[i] = {
buffer: file,
content_type: 'application/octet-stream'
value: file,
options: {
contentType: 'application/octet-stream',
filename: ''
}
};

@@ -60,0 +70,0 @@ }

var ipfs = require('./')('localhost:5001');
/*ipfs.add('/Users/mappum/Downloads/and.jpg', function(err, data) {
ipfs.add('/Users/mappum/Downloads/and.jpg', function(err, data) {
if(err) return console.error(err)
console.log(data)
});*/
ipfs.object.get('QmeZy1fGbwgVSrqbfh9fKQrAWgeyRnj7h8fsHS1oy3k99x', function(err, data) {
});
/*
ipfs.cat('Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9', function(err, data) {
console.log(err, data)
});
*/
{
"name": "ipfs-api",
"version": "0.0.1-2",
"version": "0.0.2",
"description": "An client library for the IPFS API",
"main": "index.js",
"dependencies": {
"needle": "^0.7.10"
"multipart-stream": "^1.0.0",
"request": "^2.48.0"
},

@@ -9,0 +10,0 @@ "devDependencies": {},

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