HomeDocs
Skip to main content

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

PropertyTypeDefaultRequiredDescription
filePathstringYesThe file path to be read (relative path) or the file/directory path to be checked for existence (relative path).
successfunctionNoCallback function that is called when the interface is successfully invoked.
failfunctionNoCallback function that is called when the interface fails to be invoked.
completefunctionNoCallback function that is called when the interface invocation ends (both successful and unsuccessful cases).

object.success Callback Function

Parameters

Object res

PropertyTypeDescription
sizenumberFile size in bytes.
successstringtrue - Set successfully.

object.fail Callback Function

Parameters

Object res

PropertyTypeDescription
errMsgstringError message.
successstringfalse - Set failed.

errMsg Description

Error MessageDescription
parameter error: F10001Invalid parameters.
fail file does not exist: F10006File 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);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.