Skip to content

Mini Program File Management

1.convert finfile paths to absolute paths

In some scenarios, we get the file path of the mini program and can't get the file data, so we can use this method to convert it to an absolute path. For example, when using the forwarding function of the mini program, the returned image path is the mini program file path, which can be converted to an absolute path using this method, and then get the image data before calling up the third party share. Another example is that in the custom api, you can pass the parameter of the mini program file path, and the host app can get the file data after converting it to an absolute path using this method.

kotlin
 /**
* Convert finfile file paths to absolute paths
* @param context
* @param appId
* @param filePath finfile file path
*/
 fun getFinFileAbsolutePath(context: Context, appId: String,
filePath: String): String?

Example of a call to ####

kotlin
val appletTempPath =
FinAppClient.appletApiManager.getFinFileAbsolutePath(this,
"60964a900f0ca30001292da1", "finfile://tmp_d412db8426d8deede4be6eac5a82476.jpg")

2.convert file paths to finfile paths

In some scenarios, you may want to convert known directories or files into FinFile paths. Here's a method to generate FinFile paths.

kotlin
 /**
* Convert a finfile protocol format path based on the path type
* @param filePath the file path
* @param pathType the path type, which is an enum variable: usr, tmp, store
*/
 fun generateFinFilePath(filePath: String, pathType: FinFilePathType): String?

Example of a call to ####

kotlin
val appletTempPath = FinAppClient.appletApiManager.generateFinFilePath("bbc/bbab/test.jpg", FinFilePathType.USR)

3. Converting FinFile Paths to Absolute Paths When Files Don't Actually Exist

In some scenarios, you may have a FinFile path but the file doesn't actually exist. You may want to convert it to an absolute path to save a file there.

For instance, if you want to save an image to mini program's path, you can first use the API: generateFinFilePath to generate a FinFile path, and then use this API to convert it to an absolute path (e.g., converting finfile://usr/bbc/bbab/test.jpg to an absolute path, which will automatically create the first two directories: bbc/bbab/). After getting the absolute path, you can save the image file to that path.

kotlin
 /**
* Converts a FinFile file path to an absolute path
     * @param context The application context
     * @param appId The app ID
     * @param filePath The FinFile file path
*/
 fun getFinFileAbsolutePathCanNoExist(context: Context, appId: String, filePath: String): String?

Example of a call to ####

kotlin
val appletTempPath = FinAppClient.appletApiManager.getFinFileAbsolutePathCanNoExist(this, "60964a900f0ca30001292da1", "finfile://usr/bbc/bbab/test.jpg")

4.Get the path to the mini program's temporary file storage directory

API

kotlin
/**
* Get the path to the mini program's temporary file storage directory
*
* @param context context
* @param appId mini program ID
Subscribe to DeepL Pro to edit this document.
Visit www.DeepL.com/profor more information.
* @return path to the directory where the mini program's temporary files are
stored
*/
fun getAppletTempPath(context: Context, appId: String): String?

Example of a call to ####

kotlin
val appletTempPath =
FinAppClient.appletApiManager.getAppletTempPath(this, "appId")
java
String appletTempPath = FinAppClient.INSTANCE.getAppletApiManager().
getAppletTempPath(this, "appId");

5.Get the path to the directory where the mini program source code is

stored

API

kotlin
/**
* Get the path to the directory where the mini program source code is stored
*
* @param context context
* @param appId mini program ID
* @return the path to the directory where the mini program source code is
stored
*/
fun getAppletSourcePath(context: Context, appId: String): String?

Example of a call to ####

kotlin
val appletSourcePath =
FinAppClient.appletApiManager.getAppletSourcePath(context, "appId")
java
String appletSourcePath = FinAppClient.INSTANCE.getAppletApiManager().
getAppletSourcePath(context, appId);