ipfs - ipfs-http-client 并同时添加到 ipfs mfs?
问题描述
目前,我有一个负责创建图像的 NodeJS 项目,并且运行良好。唯一的问题是试图弄清楚为什么当您在 ipfs-http-client 请求中使用 ipfs.add() 函数时不会同时将其添加到 ipfs 可变文件存储 (mfs)...
我做了一些搜索,我很好奇这是否会满足我的要求,以便添加的文件会显示在 ipfs 服务器 webui 上。
async function ipfsStoreAsset(db, composite_file_location, fileName, nft_id) {
// Client Setup
const client = create()
try {
// read file into Buffer
const content = fs.readFileSync(composite_file_location)
// create file object using Buffer contents
const file = { path: fileName, content: content }
// send file object to ipfs server
const ipfs_data = await client.add(file).then((ipfs_data) => {
// get the cid of the uploaded file so we can store it
let cid = ipfs_data.cid.toString()
console.log('cid: ' + cid)
db.query('...storing cid in database...', [cid, nft_id], (err, data, fields) => {
if(err) {
console.log(err)
}
})
return cid
})
// Is this going to add the cid that was created to the mfs?
await ipfs.files.cp(ipfs_data, fileName)})
} catch(err) {
console.log(err)
}
}
解决方案
推荐阅读
- java - 如何用 java.Swing 移动乒乓球拍?
- c++ - 单击错误时的Vscode“无法打开[文件]:无法读取文件”消息
- python - 有人在 macOS 上安装 CartoPY 吗?
- c++ - 为什么在我的 Linux 中,当当前工作目录由 root 拥有(例如 /usr/bin)时,我在编译 c++ 时无法链接任何库?
- css - Chrome 手机是否有一些功能可以在电池电量不足时减少 CSS 动画?
- azure-devops - 如何使用特定提交通过 Azure DevOps REST API 对新构建进行排队?
- sql - Oracle SQL 查询以获取单列中的多对多记录
- excel - 切片 URL 字符串以提取特定部分
- python - 我可以为这个大型 excel 文件数据集运行什么样的分析?
- python - python中搜索字符串和字符串列表之间的最高百分比Levenshtein距离的最快方法是什么?