Skip to content

Commit

Permalink
mobile: fix single file export on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Oct 14, 2024
1 parent ffe068d commit bd05ad6
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions apps/mobile/app/services/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bd05ad6

Please sign in to comment.