tencent cloud

Feedback

Mini program file management

Last updated: 2024-07-03 18:02:53

    Converting wxfile path to absolute path

    In some scenarios, you may need to convert a mini program file path to an absolute path to access the file data.
    For example, when using the mini program's forwarding feature, the returned image path is a mini program file path. You can convert it to an absolute path to access the image data and then initiate third-party sharing. Similarly, in custom APIs, you can pass the mini program file path as a parameter, and the host app can convert it to an absolute path to access the file data.
    Sample code:
    TMAFileManager *fm = [[TMFMiniAppSDKManager sharedInstance] getFileManagerWithAppID:appInfo.appId];
    NSString *filePath = [fm translateWxfilePathToAbsolutePath:wxPath];

    Converting absolute path to wxfile path

    The SDK supports converting file paths created in the mini program's cache directory to mini program file paths for internal use.
    Sample code:
    TMAFileManager *fm = [[TMFMiniAppSDKManager sharedInstance] getFileManagerWithAppID:appInfo.appId];
    NSString *tmpPath = [fm createMediaTmpPathWithFileName:@"a.pdf" type:TMATmpPathTypeFile needTimestamp:YES];
    NSString *wxPath = [fm translateAnyPathToWxfilePath:tmpPath];

    Creating files in the mini program temporary directory

    The SDK supports creating files in the mini program's cache directory natively.
    Sample code:
    TMAFileManager *fm = [[TMFMiniAppSDKManager sharedInstance] getFileManagerWithAppID:appInfo.appId];
    NSString *tmpPath = [fm createMediaTmpPathWithFileName:@"a.pdf" type:TMATmpPathTypeFile needTimestamp:YES];
    
    
    
    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