Using the mini program file management API, you can convert between the mini program file path and superapp’s local file path, as well as create new paths.
Note:
Mini program file path: A path identifier used by mini program developers that starts with wxfile:// . Each path beginning with wxfile:// is mapped by the mini program SDK to a local file path within the superapp.
Superapp’s local file path: The absolute path of the superapp in the device storage, such as /data/data/com.tencent.miniapp.demo/app_T1701421723ASSNID/2121/files/mini/.
Create a file in the mini program's temporary directory
The SDK enables Flutter applications to create files within the mini program's cache directory. It then returns the local paths of these files for use by the superapp.
appId: Mini program appid
appVerType: Mini program type
suffix: File type extension
Future<String?> getTmpPath(String miniAppId, int appVerType, String suffix)
Example:
Future<String?> getTmpPath(appId, appVerType, 'jpg')
Convert an absolute path to a wxfile path
The SDK supports converting a file path created natively in the mini program’s cache directory into a wxfile path used internally by the mini program.
appId: Mini program appid
appVerType: Mini program type
path: Actual file path
Future<String?> getWxFilePath(String miniAppId, int appVerType, String path)
Example:
_tcmppFlutterPlugin.getWxFilePath(appId, appVerType, path)
Convert a wxfile path to an absolute path
The SDK supports converting wxfile paths within the cache directory to full local paths for use by the superapp.
appId: Mini program appid
appVerType: Mini program type
path: wxfile file path
Future<String?> getAbsolutePath(String miniAppId, int appVerType, String path)
Example:
_tcmppFlutterPlugin.getAbsolutePath(appId, appVerType, path)