FileSystemManager.getFileInfo
Introduction
Get the size of a local temporary file or local cached file in the current mini-program.
Usage Restrictions
Supported in basic library version 3.0.0
or higher.
Parameters
Object object
Property | Type | Default | Required | Description |
---|---|---|---|---|
filePath | string | Yes | The file path to be read (relative path) or the file/directory path to be checked for existence (relative path). | |
success | function | No | Callback function that is called when the interface is successfully invoked. | |
fail | function | No | Callback function that is called when the interface fails to be invoked. | |
complete | function | No | Callback function that is called when the interface invocation ends (both successful and unsuccessful cases). |
object.success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
size | number | File size in bytes. |
success | string | true - Set successfully. |
object.fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
errMsg | string | Error message. |
success | string | false - Set failed. |
errMsg Description
Error Message | Description |
---|---|
parameter error: F10001 | Invalid parameters. |
fail file does not exist: F10006 | File does not exist. |
Sample Code
// pages/index/index.js
Page({
getFileInfo() {
const fs = dlt.getFileSystemManager();
fs.getFileInfo({
filePath: `${dlt.env.USER_DATA_PATH}/test.png`,
success: (res) => {
console.log(res);
},
});
},
});