File Manager
Methods readdirSync The synchronous version of FileSystemManager.readdir.
Reference
( dirPath : string ) => string [ ] Copy Property Type Description dirPath stringPath to the directory to be read
API Support API WeChat Mini-Program H5 React Native FileSystemManager.readdirSync ✔️
access Determines whether a file/directory exists.
Reference
( option : AccessOption ) => void Copy Property Type option AccessOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.access ✔️
accessSync The synchronous version of FileSystemManager.access.
Reference
( path : string ) => void Copy Property Type Description path stringPath to the file/directory of which you want to determine the existence
API Support API WeChat Mini-Program H5 React Native FileSystemManager.accessSync ✔️
appendFile Appends content at the end of a file.
Reference
( option : AppendFileOption ) => void Copy Property Type option AppendFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.appendFile ✔️
appendFileSync The synchronous version of FileSystemManager.appendFile.
Reference
( filePath : string , data : string | ArrayBuffer , encoding ? : "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1" ) => void Copy Property Type Description filePath stringPath to the file to which you want to append content data string | ArrayBufferText or binary data to be appended encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"Specifies the character encoding of the written file
API Support API WeChat Mini-Program H5 React Native FileSystemManager.appendFileSync ✔️
copyFile Copies files.
Reference
( option : CopyFileOption ) => void Copy Property Type option CopyFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.copyFile ✔️
copyFileSync The synchronous version of FileSystemManager.copyFile.
Reference
( srcPath : string , destPath : string ) => void Copy Property Type Description srcPath stringThe path to the source file, which can only be a normal file destPath stringThe path to the target file
API Support API WeChat Mini-Program H5 React Native FileSystemManager.copyFileSync ✔️
getFileInfo Gets the information of local temporary files or local cache files under the Mini Program.
Reference
( option : getFileInfoOption ) => void Copy Property Type option getFileInfoOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.getFileInfo ✔️
getSavedFileList Gets the list of local cache files saved under the Mini Program.
Reference
( option ? : getSavedFileListOption ) => void Copy Property Type option getSavedFileListOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.getSavedFileList ✔️
mkdir Creates a directory.
Reference
( option : MkdirOption ) => void Copy Property Type option MkdirOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.mkdir ✔️
mkdirSync The synchronous version of FileSystemManager.mkdir.
Reference
( dirPath : string , recursive ? : boolean ) => void Copy Property Type Description dirPath stringPath to the created directory recursive booleanIndicates whether to create the directory after recursively creating the upper-layer directory. If the upper-layer directory already exists, do not create it. If dirPath is a/b/c/d and "recursive" is true, directory a will be created, and then directory b will be created under directory a, and so on, until directory d under directory a/b/c is created.
API Support API WeChat Mini-Program H5 React Native FileSystemManager.mkdirSync ✔️
readFile Reads local file content.
Reference
( option : ReadFileOption ) => void Copy Property Type option ReadFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.readFile ✔️
readdir Reads the list of files in the directory.
Reference
( option : ReaddirOption ) => void Copy Property Type option ReaddirOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.readdir ✔️
removeSavedFile Deletes the local cache files saved under the Mini Program.
Reference
( option : RemoveSavedFileOption ) => void Copy Property Type option RemoveSavedFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.removeSavedFile ✔️
rename Renames a file, and moves it from oldPath to newPath.
Reference
( option : RenameOption ) => void Copy Property Type option RenameOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.rename ✔️
renameSync The synchronous version of FileSystemManager.rename.
Reference
( oldPath : string , newPath : string ) => void Copy Property Type Description oldPath stringThe path to the source file, which can be a normal file or directory newPath stringNew file path
API Support API WeChat Mini-Program H5 React Native FileSystemManager.renameSync ✔️
rmdir Deletes a directory.
Reference
( option : RmdirOption ) => void Copy Property Type option RmdirOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.rmdir ✔️
rmdirSync The synchronous version of FileSystemManager.rmdir.
Reference
( dirPath : string , recursive ? : boolean ) => void Copy Property Type Description dirPath stringThe path to the directory to be deleted. recursive booleanIndicates whether to recursively delete the directory. If the value is true, the directory and all subdirectories and files under the directory are deleted.
API Support API WeChat Mini-Program H5 React Native FileSystemManager.rmdirSync ✔️
saveFile Saves temporary files to the local device. This API moves temporary files, so tempFilePath will not be available after the API is successfully called.
Reference
( option : SaveFileOption ) => void Copy Property Type option SaveFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.saveFile ✔️
stat Gets the Stats object of the file.
Reference
( option : StatOption ) => void Copy Property Type option StatOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.stat
unlink Deletes files
Reference
( option : UnlinkOption ) => void Copy Property Type option UnlinkOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.unlink ✔️
unlinkSync The synchronous version of FileSystemManager.unlink.
Reference
( filePath : string ) => void Copy Property Type Description filePath stringPath to the file to be deleted
API Support API WeChat Mini-Program H5 React Native FileSystemManager.unlinkSync ✔️
unzip Unzips files
Reference
( option : UnzipOption ) => void Copy Property Type option UnzipOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.unzip ✔️
writeFile Writes a file
Reference
( option : WriteFileOption ) => void Copy Property Type option WriteFileOption
API Support API WeChat Mini-Program H5 React Native FileSystemManager.writeFile ✔️
writeFileSync The synchronous version of FileSystemManager.writeFile.
Reference
( filePath : string , data : string | ArrayBuffer , encoding ? : "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1" ) => void Copy Property Type Description filePath stringPath to the file into which you want to write data data string | ArrayBufferText or binary data to be written encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"Specifies the character encoding of the written file
API Support API WeChat Mini-Program H5 React Native FileSystemManager.writeFileSync ✔️
statSync The synchronous version of FileSystemManager.stat.
Reference
( path : string , recursive ? : boolean ) => Stats | Record < string , any > Copy Property Type Description path stringThe file/directory path. recursive booleanIndicates whether to recursively get the Stats information of each file under the directory.
API Support API WeChat Mini-Program H5 React Native FileSystemManager.statSync ✔️
saveFileSync The synchronous version of FileSystemManager.saveFile.
Reference
( tempFilePath : string , filePath ? : string ) => number Copy Property Type Description tempFilePath stringPath to the temporarily stored files filePath stringPath to save the files
API Support API WeChat Mini-Program H5 React Native FileSystemManager.saveFileSync ✔️
readFileSync The synchronous version of FileSystemManager.readFile.
Reference
( filePath : string , encoding ? : "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1" ) => string | ArrayBuffer Copy Property Type Description filePath stringThe path to the file to be read. encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"Specifies the character encoding of the read file. If encoding is not specified, the binary content of the file is read in ArrayBuffer format.
API Support API WeChat Mini-Program H5 React Native FileSystemManager.readFileSync ✔️
Parameters encoding Valid values of encoding
Property Description ascii base64 binary hex ucs2 Read in little endian ucs-2 Read in little endian utf16le Read in little endian utf-16le Read in little endian utf-8 utf8 latin1
AccessOption Property Type Required Description path stringYes Path to the file/directory of which you want to determine the existence complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
AccessFailCallbackResult Property Type Description errMsg stringError message Valid values: - 'fail no such file or directory path': File/directory does not exist;
AppendFileOption Property Type Required Description data string | ArrayBufferYes Text or binary data to be appended filePath stringYes Path to the file to which you want to append content encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"No Specifies the character encoding of the written file complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
AppendFileFailCallbackResult Property Type Description errMsg stringError message Valid values: - 'fail no such file or directory, open filePath': File with the specified filePath does not exist; - 'fail illegal operation on a directory, open "filePath"': The specified filePath is an existing directory; - 'fail permission denied, open dirPath': No write permission on the specified filePath; - 'fail sdcard not mounted': The SD card is not mounted;
CopyFileOption Property Type Required Description destPath stringYes The path to the target file srcPath stringYes The path to the source file, which can only be a normal file complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
CopyFileFailCallbackResult Property Type Description errMsg stringError message Valid values: - 'fail permission denied, copyFile srcPath -> destPath': No write permission on the specified target file path; - 'fail no such file or directory, copyFile srcPath ->destPath': The source file does not exist, or the upper-layer directory of the target file path does not exist; - 'fail the maximum size of the file storage limit is exceeded': Insufficient storage space;
getFileInfoOption Property Type Required Description filePath stringYes Path to the files to be read complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetFileInfoFailCallbackResult Property Type Description errMsg stringError message Valid values: - 'fail file not exist': No file found with the specified filePath;
GetFileInfoSuccessCallbackResult Property Type Description size numberFile size in bytes errMsg stringCall result
getSavedFileListOption Property Type Required Description complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
GetSavedFileListSuccessCallbackResult Property Type Description fileList GetSavedFileListSuccessCallbackResultFileItem[]File array errMsg stringCall result
GetSavedFileListSuccessCallbackResultFileItem res.fileList is composed as follows
Property Type Description createTime numberThe timestamp when the file was saved, which is defined as the number of seconds that have elapsed since 1970/01/01 08:00:00 to the current time filePath stringLocal path size numberLocal file size in bytes
MkdirOption Property Type Required Description dirPath stringYes The path to the created directory recursive booleanNo Indicates whether to create the directory after recursively creating the upper-layer directory. If the upper-layer directory already exists, do not create it. If dirPath is a/b/c/d and "recursive" is true, directory a will be created, and then directory b will be created under directory a, and so on, until directory d under directory a/b/c is created. complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
MkdirFailCallbackResult Property Type Description errMsg stringError message Valid value: - 'fail no such file or directory dirPath': The upper-layer directory does not exist; - 'fail permission denied, open dirPath': No write permission on the specified filePath; - 'fail file already exists dirPath': A file or directory with the same name already exists;
ReadFileOption Property Type Required Description filePath stringYes Path to the file to be read encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"No Specifies the character encoding of the read file. If encoding is not specified, the binary content of the file is read in ArrayBuffer format. complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
ReadFileFailCallbackResult Property Type Description errMsg stringError message. Valid value: - 'fail no such file or directory, open filePath': The directory where the specified filePath is located does not exist; - 'fail permission denied, open dirPath': No read permission on the specified filePath;
ReaddirOption Property Type Required Description dirPath stringYes Path to the directory to be read complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
ReaddirFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail no such file or directory dirPath': Directory does not exist; - 'fail not a directory dirPath': dirPath is not a directory; - 'fail permission denied, open dirPath': No read permission on the specified filePath;
ReaddirSuccessCallbackResult Property Type Description files string[]The array of file names in the specified directory. errMsg stringCall result
RemoveSavedFileOption Property Type Required Description filePath stringYes Path to the file to be deleted complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
RemoveSavedFileFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail file not exist': No file found with the specified tempFilePath;
RenameOption Property Type Required Description newPath stringYes The new path to the file oldPath stringYes The old path to the file, which can be a normal file or directory complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
RenameFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail permission denied, rename oldPath -> newPath': No write permission on the specified source file or target file; - 'fail no such file or directory, rename oldPath -> newPath': The source file does not exist, or the upper-layer directory of the target file path does not exist;
RmdirOption Property Type Required Description dirPath stringYes The path to the directory to be deleted. recursive booleanNo Indicates whether to recursively delete the directory. If the value is true, the directory and all subdirectories and files under the directory are deleted. complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
RmdirFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail no such file or directory dirPath': Directory does not exist; - 'fail directory not empty': Directory is not empty; - 'fail permission denied, open dirPath': No write permission on the specified dirPath;
SaveFileOption Property Type Required Description tempFilePath stringYes Path to the temporarily stored files filePath stringNo Path to save the files complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
SaveFileFailCallbackResult Property Type Description errMsg stringError message Valid values: - 'fail tempFilePath file not exist': No file found with the specified tempFilePath; - 'fail permission denied, open "filePath"': No write permission on the specified filePath; - 'fail no such file or directory "dirPath"': The upper-layer directory does not exist; - 'fail the maximum size of the file storage limit is exceeded': Insufficient storage space;
SaveFileSuccessCallbackResult Property Type Description savedFilePath numberPath to the saved file errMsg stringCall result
StatOption Property Type Required Description path stringYes The file/directory path. recursive booleanNo Indicates whether to recursively get the Stats information of each file under the directory. complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
StatFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail permission denied, open path': No read permission on the specified path; - 'fail no such file or directory path': File does not exist;
StatSuccessCallbackResult Property Type Description stats Stats | Record<string, any>Stats errMsg stringCall result
UnlinkOption Property Type Required Description filePath stringYes Path to the file to be deleted complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
UnlinkFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail permission denied, open path': No read permission on the specified path; - 'fail no such file or directory path': File does not exist; - 'fail operation not permitted, unlink filePath': The passed filePath is a directory;
UnzipOption Property Type Required Description targetPath stringYes The path to the target directory zipFilePath stringYes The path to the source file, which can only be a zip file complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
UnzipFailCallbackResult Property Type Description errMsg stringError message. Valid values: - 'fail permission denied, unzip zipFilePath -> destPath': No write permission on the specified target file path; - 'fail no such file or directory, unzip zipFilePath -> "destPath': The source file does not exist, or the upper-layer directory of the target file path does not exist;
WriteFileOption Property Type Required Description data string | ArrayBufferYes Text or binary data to be written filePath stringYes Path to the file into which you want to write data encoding "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"No Specifies the character encoding of the written file complete (res: any) => voidNo The callback function used when the API call completed (always executed whether the call succeeds or fails) fail (res: any) => voidNo The callback function for a failed API call success (res: Result) => voidNo The callback function for a successful API call
WriteFileFailCallbackResult Property Type Description errMsg stringError message. Valid valus: - 'fail no such file or directory, open filePath': The directory where the specified filePath is located does not exist; - 'fail permission denied, open dirPath': No write permission on the specified filePath; - 'fail the maximum size of the file storage limit is exceeded': Insufficient storage space;
API Support API WeChat Mini-Program H5 React Native FileSystemManager.readdirSync ✔️ FileSystemManager.access ✔️ FileSystemManager.accessSync ✔️ FileSystemManager.appendFile ✔️ FileSystemManager.appendFileSync ✔️ FileSystemManager.copyFile ✔️ FileSystemManager.copyFileSync ✔️ FileSystemManager.getFileInfo ✔️ FileSystemManager.getSavedFileList ✔️ FileSystemManager.mkdir ✔️ FileSystemManager.mkdirSync ✔️ FileSystemManager.readFile ✔️ FileSystemManager.readdir ✔️ FileSystemManager.removeSavedFile ✔️ FileSystemManager.rename ✔️ FileSystemManager.renameSync ✔️ FileSystemManager.rmdir ✔️ FileSystemManager.rmdirSync ✔️ FileSystemManager.saveFile ✔️ FileSystemManager.stat FileSystemManager.unlink ✔️ FileSystemManager.unlinkSync ✔️ FileSystemManager.unzip ✔️ FileSystemManager.writeFile ✔️ FileSystemManager.writeFileSync ✔️ FileSystemManager.statSync ✔️ FileSystemManager.saveFileSync ✔️ FileSystemManager.readFileSync ✔️