Skip to content

Commit

Permalink
Merge pull request #24 from aragon/expose-http
Browse files Browse the repository at this point in the history
Expose http storage provider
  • Loading branch information
izqui authored Aug 13, 2018
2 parents cd75a2e + bb5eba3 commit 9e3c52f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const ipfs = require('./providers/ipfs')
const ens = require('./ens')
const semver = require('semver')
const promiseTimeout = require('./utils/timeout-promise.js')

const ipfs = require('./providers/ipfs')
const http = require('./providers/http')

const GAS_FUZZ_FACTOR = 1.5
const GET_INFO_TIMEOUT = 10000 //ms

Expand All @@ -18,7 +20,8 @@ module.exports = (web3, options = {}) => {

// Set up providers
const defaultProviders = {
ipfs: ipfs(options.ipfs)
ipfs: ipfs(options.ipfs),
http: http(),
}
const providers = Object.assign(
defaultProviders,
Expand Down
5 changes: 3 additions & 2 deletions src/providers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = () => {
* @return {Promise} A promise that resolves to the contents of the file
*/
getFile (host, path) {
return axios(`${host}/${path}`, {
const protocol = new RegExp('^https?://').test(host) ? '' : 'http://'
return axios(`${protocol}${host}/${path}`, {
responseType: 'text',

// This is needed to disable the default behavior of axios, which
Expand Down Expand Up @@ -43,7 +44,7 @@ module.exports = () => {
* @param {string} url The url where the content will be served
* @return {Promise} A promise that resolves to the content URI of the files
*/
async uploadFiles (url) {
uploadFiles (url) {
// We won't actually upload files since we will just
// assume that files are available on this URL indefinitely.
//
Expand Down

0 comments on commit 9e3c52f

Please sign in to comment.