IpfsHttpApi

IpfsHttpApi

A Class used for uploading/adding files to IPFS




Constructor

new IpfsHttpApi(file, options)

Create a new IPFS Node.js Add

Parameters:
Name Type Description
file Buffer | ReadableStream | PullStream

The File or Blob you want added to IPFS.

options Object

The Options for this Upload

Properties
Name Type Attributes Description
host String

The hostname of the IPFS API server to upload to (i.e. "ipfs-dev.alexandria.io")

protocol String

The Protocol of the IPFS API server to upload to (i.e. "https")

port Number

The Port of the IPFS API server to upload to (i.e. 443)

oip_auth Object

An object that contains a signed message, the address that signed the message, and the signature for them both

filename String <optional>

The filename/path of the Item you are uploading

filesize String <optional>

The size of the Item you are uploading. You must include this if you want valid progress reports.

Source:

Methods




onProgress(progress_function)

Subscribe to upload Progress events

Parameters:
Name Type Description
progress_function function

The function you want called when there is a progress update available

Source:
Example
let uploader = new IPFSBrowserAdd(input.files[0], {
 "api_url": "https://ipfs-dev.alexandria.io",
 "oip_auth": {
   address:"oNRs1nuR1vUAjWJwhMtxJPQoTFAm9MWz1G",
   message:'1534278675842{"oip042":{}}',
   signature:"Hw2iuomv/fhYYoKX8bNroVXmOvbh/e9gqZjP+I9kZymHD72mqtDw1qjN6/Qh4nhTDOHI8mkxbWtsaLSTuCkSihU="
 }
})

uploader.onProgress((progress_message) => {
 console.log("Progress! " + JSON.stringify(progress_message))
})



(async) start() → {Promise.<Object>}

Start the File Upload to the server

Source:
Example
let uploader = new IPFSBrowserAdd(input.files[0], {
 "api_url": "https://ipfs-dev.alexandria.io",
 "oip_auth": {
   address:"oNRs1nuR1vUAjWJwhMtxJPQoTFAm9MWz1G",
   message:'1534278675842{"oip042":{}}',
   signature:"Hw2iuomv/fhYYoKX8bNroVXmOvbh/e9gqZjP+I9kZymHD72mqtDw1qjN6/Qh4nhTDOHI8mkxbWtsaLSTuCkSihU="
 }
})

uploader.onProgress((progress_message) => {
 console.log("Progress! " + JSON.stringify(progress_message))
})

uploader.start().then((success_response) => {
 console.log("Upload Complete! " + JSON.stringify(success_response))
})
Returns:

Returns a Promise that will resolve to the IPFS Added object JSON

Type:
Promise.<Object>