统一pickupFile2Server, pickupFile2Cloud, pickupFile的返回对象为 { _state, ?fileUrl, ...rest }
This commit is contained in:
parent
78aa044f63
commit
ed70ded908
19
index.js
19
index.js
@ -203,7 +203,7 @@ module.exports = {
|
|||||||
let [errorChoose, { tempFilePath }] = await uni.chooseVideo({ sourceType })
|
let [errorChoose, { tempFilePath }] = await uni.chooseVideo({ sourceType })
|
||||||
filePath = tempFilePath
|
filePath = tempFilePath
|
||||||
} else {
|
} else {
|
||||||
return [{ _ERROR: 'UNKNOWN_MEDIATYPE' }, null]
|
return { _state: 'UNKNOWN_MEDIATYPE' }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
@ -218,14 +218,8 @@ module.exports = {
|
|||||||
// url 所在方法进一步处理后,通过 uploadFile 存在 data 里返回结果
|
// url 所在方法进一步处理后,通过 uploadFile 存在 data 里返回结果
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
||||||
if (typeof(data)==='string') {
|
|
||||||
try {
|
|
||||||
data = JSON.parse(data)
|
|
||||||
} catch (exception) {}
|
|
||||||
}
|
|
||||||
// return [errorUpload, response]
|
|
||||||
if (data) {
|
if (data) {
|
||||||
return { _state: 'SUCCESS', file: data }
|
return { _state: 'SUCCESS', fileUrl: data ? this.makeServerUrl(data.webpath || data.path) : undefined, ...data }
|
||||||
}else {
|
}else {
|
||||||
return { _state: 'CLIENT_FAIL_UPLOAD_FILE', errorUpload }
|
return { _state: 'CLIENT_FAIL_UPLOAD_FILE', errorUpload }
|
||||||
}
|
}
|
||||||
@ -289,9 +283,8 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
||||||
console.log('文件上传结果:', { fileID, requestId })
|
|
||||||
if (fileID) {
|
if (fileID) {
|
||||||
return { _state: 'SUCCESS', fileID, requestId }
|
return { _state: 'SUCCESS', fileUrl: fileID, requestId }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { _state: 'CLIENT_FAIL_CHOOSE_FILE' }
|
return { _state: 'CLIENT_FAIL_CHOOSE_FILE' }
|
||||||
@ -304,10 +297,12 @@ module.exports = {
|
|||||||
}) {
|
}) {
|
||||||
if (backend==='UNICLOUD'){
|
if (backend==='UNICLOUD'){
|
||||||
const resultCloud = await this.pickupFile2Cloud({mediaType, count, sizeType, sourceType, maxDuration })
|
const resultCloud = await this.pickupFile2Cloud({mediaType, count, sizeType, sourceType, maxDuration })
|
||||||
return Object.assign(resultCloud, { fileUrl: resultCloud.fileID })
|
this.colog(resultCloud)
|
||||||
|
return resultCloud
|
||||||
}else if (backend==='SERVER' && url){
|
}else if (backend==='SERVER' && url){
|
||||||
const resultServer = await this.pickupFile2Server({mediaType, count, sizeType, sourceType, maxDuration, url, header, formData, name})
|
const resultServer = await this.pickupFile2Server({mediaType, count, sizeType, sourceType, maxDuration, url, header, formData, name})
|
||||||
return Object.assign(resultServer, {fileUrl: resultServer.file ? this.makeServerUrl(resultServer.file.webpath || resultServer.file.path) : undefined})
|
this.colog(resultServer)
|
||||||
|
return resultServer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user