Gerenciamento de arquivos de applet
1. Converter caminhos finfile em caminhos absolutos
Em alguns SCONARIOS, obtemos o caminho do arquivo do applet e não podemos os dados do arquivo, para que possamos usar esse método para convertê -lo em um caminho absoluto.
Por exemplo, quando usada a função de encaminhamento do applet, o caminho da imagem Returnet é o caminho do arquivo de applet, para que você possa usar esse método para convertê -lo em patos absolutos e, em seguida, os dados da imagem e iniciar o terceiro-Compartilhamento de festas. Por exemplo, na API personalizada, você pode passar no parâmetro do caminho do arquivo de applet e o aplicativo host pode obter os dados do arquivo após convertê -los em um caminho absoluto com esse método.
/**
Converts the file path to an absolute path
If it is a network file path, it is returned directly.
If it is a path in the phizclip, such as finfile://tmp_fdfdkfjdkfjdkjfdkjf.jpg, it will be converted to a local absolute path
If it is a file path in a small package, such as image/xxx.jpg, it will also be converted to an absolute path
In other cases, the incoming path is returned
@param path File path
@return The absolute path to the file
*/
- (NSString *)fat_absolutePathWithPath:(NSString *)path;Exemplo Código:
NSString *finfilePath = @ "finfile://tmp_7C82E6C26B7627334E88355E9D286621.mp4" ;
NSString *path = [[FATClient sharedClient] fat_absolutePathWithPath:filePath];2. Salve o arquivo no diretório de temperos atuais do applet
O SDK suporta salvar arquivos nativamente no diretório de cache do applet e depois retornar o pato local o arquivo para uso pelo applet.
/**
Save the file to the cache path of the applet
@param fileData The binary data of the file
@param fileName file name, you need to ensure that the file name is unique, otherwise it may be overwritten
@return The local path of the file, for example: finfile://tmp_fdfdkfjdkfjdkjfdkjf.jgp
*/
- (NSString *)saveFile:(NSData *)fileData fileName:(NSString *)fileName;