修改未完成
This commit is contained in:
@@ -134,6 +134,27 @@ const pickBrowserVideo = () => new Promise((resolve, reject) => {
|
||||
});
|
||||
|
||||
const readNativeFile = (filePath) => new Promise((resolve, reject) => {
|
||||
if (typeof globalThis.uni?.getFileInfo === 'function') {
|
||||
const normalizedPath = String(filePath || '')
|
||||
const fileName = normalizedPath.split(/[\\/]/).pop() || 'file'
|
||||
try {
|
||||
globalThis.uni.getFileInfo({
|
||||
filePath,
|
||||
digestAlgorithm: 'md5',
|
||||
success: (file) => resolve({
|
||||
filePath,
|
||||
fileName,
|
||||
size: file.size,
|
||||
contentType: 'application/octet-stream',
|
||||
md5: String(file.digest || '').toLowerCase()
|
||||
}),
|
||||
fail: () => reject(createUploadError('读取图片信息失败', 'IMAGE_READ_FAILED'))
|
||||
})
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!globalThis.plus?.io?.resolveLocalFileSystemURL || !globalThis.plus?.io?.FileReader) {
|
||||
reject(createUploadError("当前运行环境不支持读取图片", "IMAGE_READ_UNAVAILABLE"));
|
||||
return;
|
||||
@@ -202,7 +223,7 @@ export const pickAndUploadImage = async ({ requestController = null } = {}) => {
|
||||
if (!Number.isSafeInteger(file.size) || file.size <= 0) {
|
||||
throw createUploadError("所选图片大小无效", "IMAGE_SIZE_INVALID");
|
||||
}
|
||||
const fileMd5 = calcMD5Bytes(file.data);
|
||||
const fileMd5 = file.md5 || calcMD5Bytes(file.data);
|
||||
const initPayload = {
|
||||
uploadId: createUploadId(),
|
||||
fileName: file.fileName,
|
||||
@@ -245,7 +266,7 @@ export const pickAndUploadVideo = async ({ requestController = null } = {}) => {
|
||||
if (!Number.isSafeInteger(file.size) || file.size <= 0) {
|
||||
throw createUploadError("所选视频大小无效", "VIDEO_SIZE_INVALID");
|
||||
}
|
||||
const fileMd5 = calcMD5Bytes(file.data);
|
||||
const fileMd5 = file.md5 || calcMD5Bytes(file.data);
|
||||
const initPayload = {
|
||||
uploadId: createUploadId(),
|
||||
fileName,
|
||||
|
||||
Reference in New Issue
Block a user