diff --git a/.gitignore b/.gitignore index dc3e90b..2ecfc91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,63 +1,97 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. -node_modules/ +### 目录 ################################################################# + +# wo-服务端 +/_archive/* +/_datastore/* +/_filestore/* +/_logstore/* +/_webroot/* +/_ssl/* + /test/unit/coverage/ /test/e2e/reports/ -.svn/ -.idea/ -.sass-cache/ -.deploy_git/ -.gitattributes -_desktop.ini -.DS_Store -.thumbnails -Thumbs.db -thumbs.db -.umi -.umi-production -npm-debug.log* -yarn-debug.log* -yarn-error.log* -selenium-debug.log -package-lock.json -*.iml -*.njsproj -*.ntvs* -*.sln -*.suo -._* -.$* -~$* -.bashrc_custom - -# hexo -db.json - -# 客户端 uniapp 项目 +# uniapp 项目 /unpackage/* !/unpackage/res/ -/_archive/* -/_datastore/* -/_logstore/* -/_filestore/* -/_webroot/* +# vue-cli 项目 /dist/ + +# hexo +/public/ + +.svn/ +.deploy_git/ +.idea/ +.sass-cache/ + +node_modules/ + + +### 文件 ################################################################### + +# seafile 临时文件 +._* + +.$* + +# office 暂存文件 +~$* + *.apk *.min.js *.min.css *.min.html -/pages4loader.json5 -envar-web-custom.js -envar-deploy-secret.js +*.iml +*.njsproj +*.ntvs* +*.sw* +*.sln +*.suo -# hexo 项目 -public/ +.bashrc_custom -# 服务端(server or uniapp-uniCloud)项目 -envar-base-custom.js -envar-base-dynamic.js -envar-base-secret.js +# 苹果系统临时文件 +.DS_Store + +.gitattributes + +# 来自 vue-cli 创建项目的 .gitignore +.project + +# 安卓缓存文件夹 +.thumbnails + +.umi +.umi-production + +# local env files +.env.local +.env.*.local + +_desktop.ini + +# hexo +/db.json + +# wo-客户端环境配置,wo-服务端环境配置(server or uniapp-uniCloud) +envar-*.gitignore.js + +npm-debug.log* + +yarn-debug.log* +yarn-error.log* +yarn.lock + +package-lock.json +pages4loader.json5 + +selenium-debug.log + +Thumbs.db +thumbs.db !.gitkeep diff --git a/fileloader.js b/fileloader.js index 0ac79e0..3c31fba 100644 --- a/fileloader.js +++ b/fileloader.js @@ -26,11 +26,21 @@ module.exports = { }).single('file'), api: { - receiveFile () { + async receiveFile () { const file = wo._req?.file if (file?.path) { file.path = file.path.replace('\\', '/') - return Object.assign(file, { _state: 'SUCCESS' }) + if (wo?.ipfsStore) { + const ipfsResult = await wo.ipfsStore.add(file, { + cidVersion: 1, + hashAlg: 'sha2-256', + onlyHash: true, + pin: false, + }) + file.cid = ipfsResult?.cid?.toString() // + path.extname(file.filename) + file.ipfsUrl = wo.envar.ipfsGateway + file.cid + } + return { _state: 'SUCCESS', ...file } } else { return { _state: 'WOBASE_FAIL_FILE_NOT_RECEIVED' } }