mobile: fix single file export on ios

This commit is contained in:
Ammar Ahmed
2024-10-14 12:53:55 +05:00
committed by Ammar Ahmed
parent ffe068dbd5
commit bd05ad6548

View File

@@ -256,6 +256,7 @@ async function exportNote(
}
if (!hasAttachments) {
console.log("creating file...");
return createFile(noteItem as ExportableNote, type, path, cacheFolder);
} else {
return createZip(1, cacheFolder, type, path, callback);
@@ -314,15 +315,23 @@ async function createFile(
path: string,
cacheFolder: string
) {
const file = await ScopedStorage.createFile(
path,
basename(noteItem?.path as string),
FileMime[type]
);
const exportedFile = join(cacheFolder, noteItem?.path as string);
await copyFileAsync("file://" + exportedFile, file.uri);
let filePath: string;
if (Platform.OS === "android") {
const file = await ScopedStorage.createFile(
path,
basename(noteItem?.path as string),
FileMime[type]
);
await copyFileAsync("file://" + exportedFile, file.uri);
filePath = file.uri;
} else {
filePath = join(path, basename(noteItem.path));
await RNFetchBlob.fs.mv(exportedFile, filePath);
}
return {
filePath: file.uri,
filePath: filePath,
fileDir: path,
type: FileMime[type],
name: type,