tencent cloud

All product documents
Tencent Cloud Super App as a Service
Mini Program File Management
Last updated: 2024-11-21 17:28:50
Mini Program File Management
Last updated: 2024-11-21 17:28:50
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/.
All mini program files are managed by IMiniAppFileManager which can be obtained from the mini program context IMiniAppContext. IMiniAppContext can be accessed via  BaseJsPlugin.
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?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon