mirror of
https://github.com/embarklabs/swarm-api.git
synced 2026-08-27 15:51:16 +00:00
a9fe1ff3137398a656d2e6178f38495df392dff4
Somehow when embark webpacks the dapp, it is still seeing the ‘fs’ object, which of course it doesn’t know about, so it is complaining about a missing module. Any help would be greatly appreciated.
Documentation needs to be updated. Please completely disregard for now.
swarmjs
This library can be used to upload/download files to Swarm via https://swarm-gateways.net/ (or an optionally provided gateway).
Note that while this is a convenient feature as of today, it may not be present indefinitely.
Library usage
const swarmjs = require('swarmjs')(/* opts */)
// This should output the hash: 931cc5a6bd57724ffd1adefc0ea6b4f0235497fca9e4f9ae4029476bcb51a8c6
swarmjs.put('Hello from swarmjs!', function (err, ret) {
if (err) {
console.log('Failed to upload: ' + err)
} else {
console.log('Swarm hash: ' + ret)
}
})
// This should output the content: Hello from swarmjs!
swarmjs.get('bzz-raw://931cc5a6bd57724ffd1adefc0ea6b4f0235497fca9e4f9ae4029476bcb51a8c6', function (err, ret) {
if (err) {
abort('Failed to download: ' + err)
} else {
console.log(ret)
}
})
The opts above is a map of options:
gateway: supply your own gateway URL, if not provided, it will use "swarm-gateways.net"mode: can behttporhttps(default ishttps), ignore ifgatewayis provided
CLI usage
It can also be used via the command line if installed globally (npm install -g swarmjs). To see the help: swarmjs --help.
License
MIT License
Languages
JavaScript
97.7%
HTML
2.3%