IpfsXml

IpfsXml

A Class used for uploading/adding files to IPFS inside the Browser




Constructor

new IpfsXml(file, options)

Create a new XML HTTP Request IPFS Uploader

Parameters:
Name Type Description
file File | Blob

The File or Blob you want added to IPFS.

options Object

The Options for this Upload

Properties
Name Type 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

Source:

Methods




onProgress(progressFunction)

Subscribe to upload Progress events

Parameters:
Name Type Description
progressFunction function

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

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

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



start() → {Promise.<Object>}

Start the File Upload to the server

Source:
Example
let uploader = new XMLRequestIPFSAdd(input.files[0], {
 "host": "ipfs-dev.alexandria.io",
 "protocol": "https",
 "port": 443,
 "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>