提交 b9790db4 编写于 作者: Q qiang

feat: H5端 uni.uploadFile 支持传入 File 对象

上级 9e2de20d
......@@ -9,6 +9,9 @@ export const uploadFile = {
files: {
type: Array
},
file: {
type: File
},
filePath: {
type: String,
validator (value, params) {
......
......@@ -45,6 +45,7 @@ class UploadTask {
*/
export function uploadFile ({
url,
file,
filePath,
name,
files,
......@@ -59,6 +60,7 @@ export function uploadFile ({
if (!Array.isArray(files) || !files.length) {
files = [{
name,
file,
uri: filePath
}]
}
......@@ -128,7 +130,7 @@ export function uploadFile ({
}
Promise
.all(files.map(({ name, uri }) => urlToFile(uri)))
.all(files.map(({ file, uri }) => file instanceof File ? Promise.resolve(file) : urlToFile(uri)))
.then(upload)
.catch(() => {
setTimeout(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册