tencent cloud

Feedback

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);
    
    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 avaliable.

    7x24 Phone Support