backend server return filePath

This commit is contained in:
陆柯 2021-09-05 14:32:02 +08:00
parent a894117881
commit fb41c26f5b

View File

@ -218,8 +218,8 @@ module.exports = {
uni.showLoading()
let [errorUpload, { data, statusCode } = {}] = await uni.uploadFile({ url: this.makeServerUrl(url), filePath, name, header, formData })
// url 用后台 Multer 处理返回 { _state, filename, originalname, mimetype, size, path },
// uni.uploadFile 存在 data 里返回
// 后台 Multer 处理 req.file = { destination, filename, originalname, path, mimetype, size },
// url 所在方法进一步处理后,通过 uploadFile 存在 data 里返回结果
uni.hideLoading()
if (typeof(data)==='string') {
@ -236,8 +236,6 @@ module.exports = {
}else {
return { _state: 'CLIENT_FAIL_CHOOSE_FILE' }
}
return [{ _ERROR: 'USER_CANCELED' }, null]
},
async pickupFile2Cloud({ mediaType = 'image', count = 1, sizeType = ['original', 'compressed'], sourceType = ['album', 'camera'], maxDuration } = {}) {
@ -313,7 +311,7 @@ module.exports = {
return Object.assign(resultCloud, { fileUrl: resultCloud.fileID })
}else if (backend==='SERVER' && url){
const resultServer = await this.pickupFile2Server({mediaType, count, sizeType, sourceType, maxDuration, url, header, formData, name})
return Object.assign(resultServer, {fileUrl: resultServer.file ? this.makeBgUrl(resultServer.file.filename) : undefined})
return Object.assign(resultServer, {fileUrl: resultServer.file ? this.makeServerUrl(resultServer.file.filePath || resultServer.file.filename) : undefined})
}
},