return cid, ipfsUrl
This commit is contained in:
parent
f7a7a72414
commit
4a23a35e95
126
.gitignore
vendored
126
.gitignore
vendored
@ -1,63 +1,97 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# 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/unit/coverage/
|
||||||
/test/e2e/reports/
|
/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
|
# uniapp 项目
|
||||||
|
|
||||||
# hexo
|
|
||||||
db.json
|
|
||||||
|
|
||||||
# 客户端 uniapp 项目
|
|
||||||
/unpackage/*
|
/unpackage/*
|
||||||
!/unpackage/res/
|
!/unpackage/res/
|
||||||
|
|
||||||
/_archive/*
|
# vue-cli 项目
|
||||||
/_datastore/*
|
|
||||||
/_logstore/*
|
|
||||||
/_filestore/*
|
|
||||||
/_webroot/*
|
|
||||||
/dist/
|
/dist/
|
||||||
|
|
||||||
|
# hexo
|
||||||
|
/public/
|
||||||
|
|
||||||
|
.svn/
|
||||||
|
.deploy_git/
|
||||||
|
.idea/
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
|
||||||
|
### 文件 ###################################################################
|
||||||
|
|
||||||
|
# seafile 临时文件
|
||||||
|
._*
|
||||||
|
|
||||||
|
.$*
|
||||||
|
|
||||||
|
# office 暂存文件
|
||||||
|
~$*
|
||||||
|
|
||||||
*.apk
|
*.apk
|
||||||
*.min.js
|
*.min.js
|
||||||
*.min.css
|
*.min.css
|
||||||
*.min.html
|
*.min.html
|
||||||
/pages4loader.json5
|
*.iml
|
||||||
envar-web-custom.js
|
*.njsproj
|
||||||
envar-deploy-secret.js
|
*.ntvs*
|
||||||
|
*.sw*
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
|
||||||
# hexo 项目
|
.bashrc_custom
|
||||||
public/
|
|
||||||
|
|
||||||
# 服务端(server or uniapp-uniCloud)项目
|
# 苹果系统临时文件
|
||||||
envar-base-custom.js
|
.DS_Store
|
||||||
envar-base-dynamic.js
|
|
||||||
envar-base-secret.js
|
.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
|
!.gitkeep
|
||||||
|
@ -26,11 +26,21 @@ module.exports = {
|
|||||||
}).single('file'),
|
}).single('file'),
|
||||||
|
|
||||||
api: {
|
api: {
|
||||||
receiveFile () {
|
async receiveFile () {
|
||||||
const file = wo._req?.file
|
const file = wo._req?.file
|
||||||
if (file?.path) {
|
if (file?.path) {
|
||||||
file.path = file.path.replace('\\', '/')
|
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 {
|
} else {
|
||||||
return { _state: 'WOBASE_FAIL_FILE_NOT_RECEIVED' }
|
return { _state: 'WOBASE_FAIL_FILE_NOT_RECEIVED' }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user