add a second parameter '' to ipfsProvider.globSource(...)

This commit is contained in:
陆柯 2023-07-24 12:04:22 +08:00
parent 90c71f66cf
commit 8ce54673c2

View File

@ -42,7 +42,8 @@ module.exports = {
if (wo?.ipfsStore) { if (wo?.ipfsStore) {
// 为了在这里使用 wo.ipfsStore.add, 需要提供 FileContent不能直接用 req.file // 为了在这里使用 wo.ipfsStore.add, 需要提供 FileContent不能直接用 req.file
// 20230312: not working with nodejs above (not including) 18.2.1! https://github.com/nodejs/node/issues/46221 // 20230312: not working with nodejs above (not including) 18.2.1! https://github.com/nodejs/node/issues/46221
const { cid } = await wo.ipfsStore.add(ipfsProvider.globSource(_file.path), { const { cid } = await wo.ipfsStore.add(ipfsProvider.globSource(_file.path, ''), {
// 20230713 不知为何今天在本机测试时ipfs-core 报错 Pattern must be a string之前没有过这个问题。跟踪后发现 ipfs-core 0.14.3 代码里 第二个参数 patter 必须是 string于是添加第二个参数为 '',现在可以上传文件给本地的 ipfs-core 了。经测试,加不加这个参数都不影响 ipfs-http-client 运行。
cidVersion: 1, cidVersion: 1,
hashAlg: 'sha2-256', hashAlg: 'sha2-256',
onlyHash: false, // 多个备份是好的,而且能加快下次添加同样文件的速度。 onlyHash: false, // 多个备份是好的,而且能加快下次添加同样文件的速度。