The mini program file management API allows for the conversion and creation of file paths between the mini program and the host application's local storage.
Note:
Mini program file path: A path starting with wxfile://, used by mini program developers. The mini program SDK maps these paths to local file paths within the host application.
Host app local file path: An absolute path in the host application's storage, e.g., /data/data/com.tencent.miniapp.demo/app_T1701421723ASSNID/2121/files/mini/.
IMiniAppFileManager fileManager = mMiniAppContext.getManager(IMiniAppFileManager.class)
CREATING FILES IN THE MINI PROGRAM TEMPORARY DIRECTORY
The SDK supports creating files in the mini program's cache directory and returns the local path for the host app to use.
Sample code:
String tmpPath = fileManager.getTmpPath(".jpg");
Converting absolute paths to wxfile paths
The SDK can convert file paths created in the mini program's cache directory to paths usable by the mini program.
Sample code:
String wxfile = fileManager.getWxFilePath(path);
wxfile paths converted to absolute paths
The SDK supports converting wxfile paths in the cache directory to local paths.
Sample code:
String path = fileManager.getAbsolutePath(wxfile);
Was this page helpful?