@aragon/apm
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
{ | ||
"name": "@aragon/apm", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"description": "JavaScript library for the Aragon Package Manager", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -30,3 +30,3 @@ const ipfs = require('./providers/ipfs') | ||
const readFileFromApplication = (contentURI, path) => { | ||
const getProviderFromURI = (contentURI, path) => { | ||
const [contentProvider, contentLocation] = contentURI.split(/:(.+)/) | ||
@@ -42,5 +42,15 @@ | ||
return providers[contentProvider].getFile(contentLocation, path) | ||
return { provider: providers[contentProvider], location: contentLocation } | ||
} | ||
const readFileFromApplication = (contentURI, path) => { | ||
const { provider, location } = getProviderFromURI(contentURI, path) | ||
return provider.getFile(location, path) | ||
} | ||
const readFileStreamFromApplication = (contentURI, path) => { | ||
const { provider, location } = getProviderFromURI(contentURI, path) | ||
return provider.getFileStream(location, path) | ||
} | ||
const getApplicationInfo = (contentURI) => { | ||
@@ -82,2 +92,3 @@ return Promise.all([ | ||
getFile: readFileFromApplication, | ||
getFileStream: readFileStreamFromApplication, | ||
@@ -84,0 +95,0 @@ /** |
@@ -23,3 +23,15 @@ const got = require('got') | ||
}, | ||
/** | ||
* Gets the file stream at `path` from the content URI `hash`. | ||
* | ||
* @param {string} hash The content URI hash | ||
* @param {string} path The path to the file | ||
* @return {Stream} A stream representing the content of the file | ||
*/ | ||
getFileStream (host, path) { | ||
return got.stream(`${host}/${path}`) | ||
}, | ||
/** | ||
* Uploads all files from `path` and returns the content URI for those files. | ||
@@ -26,0 +38,0 @@ * |
@@ -20,3 +20,15 @@ const ipfsAPI = require('ipfs-api') | ||
}, | ||
/** | ||
* Gets the file stream at `path` from the content URI `hash`. | ||
* | ||
* @param {string} hash The content URI hash | ||
* @param {string} path The path to the file | ||
* @return {Stream} A stream representing the content of the file | ||
*/ | ||
getFileStream (hash, path) { | ||
return ipfs.files.catReadableStream(`${hash}/${path}`) | ||
}, | ||
/** | ||
* Uploads all files from `path` and returns the content URI for those files. | ||
@@ -23,0 +35,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52647
687