在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:fiatjaf/ipfs-dropzone开源软件地址:https://github.com/fiatjaf/ipfs-dropzone开源编程语言:JavaScript 100.0%开源软件介绍:Instead of uploading the dropped files to an URL, this subclass of Dropzone.js publishes them to IPFS with js-ipfs (no running local nodes needed). Both ipfs and dropzone are peer dependencies. Usageconst IPFSDropzone = require('ipfs-dropzone')
let dz = IPFSDropzone('#files', {
/*
the name of the repo which will store the IPFS blocks in the browser.
this name will be used by IPFS to create the IndexedDB databases.
defaults to "ipfs-dropzone"
*/
ipfsRepoName: 'filemap.xyz',
/*
ipfsPath is a function that takes the dropzone file object
and returns a string that will be used as the path when calling
https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add
defaults to (file) => file.name
*/
ipfsPath: file => file.name
// all other options you'll normally pass to dropzone go here.
})
dz.on('success', file => {
/*
everywhere the normal dropzone file object will now have a
property called "ipfs" which contains the result to the call to
https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add
*/
console.log('file published to ipfs: ' + file.ipfs[0].hash)
/*
your dropzone object will also have the property "node", which
resolves to the IPFS node the dropzone object is using.
it is a Promise because the IPFS node is only initialized at the
moment of the first file upload.
*/
dz.node.then(ipfs => {
ipfs.files.cat(file.hash, (err, file) => {
console.log(file.toString('utf-8'))
})
})
}) Information
What is the LICENSE?The MIT License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论