diff --git a/src/platforms/h5/helpers/todo-api.js b/src/platforms/h5/helpers/todo-api.js index 4294ebab27f7109b6feb728f4ecc6986a58bc2b4..a92df02d8fb389aced943a176328791fb0bd09c4 100644 --- a/src/platforms/h5/helpers/todo-api.js +++ b/src/platforms/h5/helpers/todo-api.js @@ -9,7 +9,6 @@ export default [ 'getSavedFileList', 'getSavedFileInfo', 'removeSavedFileInfo', - 'getFileInfo', 'onMemoryWarning', 'onGyroscopeChange', 'startGyroscope', diff --git a/src/platforms/h5/service/api/file/file.js b/src/platforms/h5/service/api/file/file.js new file mode 100644 index 0000000000000000000000000000000000000000..d9fecfeb1c141816a14334c7f39c34960a7b3974 --- /dev/null +++ b/src/platforms/h5/service/api/file/file.js @@ -0,0 +1,25 @@ +import { + urlToFile +} from 'uni-platform/helpers/file' + +const { + invokeCallbackHandler: invoke +} = UniServiceJSBridge + +export function getFileInfo ({ + filePath +} = {}, callbackId) { + // TODO 计算文件摘要 + urlToFile(filePath).then((res) => { + invoke(callbackId, { + errMsg: 'getFileInfo:ok', + size: res.size + }) + }).catch((err) => { + invoke(callbackId, { + errMsg: 'getFileInfo:fail 文件[' + + filePath + + '] getFileInfo 失败:' + err.message + }) + }) +}