tencent cloud

Mini Program File Management
最終更新日:2024-11-21 17:58:08
Mini Program File Management
最終更新日: 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];



この記事はお役に立ちましたか?
営業担当者に お問い合わせ いただくか チケットを提出 してサポートを求めることができます。
はい
いいえ

フィードバック