tencent cloud

All product documents
Tencent Cloud Super App as a Service
Mini Program File Management
Last updated: 2024-11-21 17:58:08
Mini Program File Management
Last updated: 2024-11-21 17:58:08

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];



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