Skip to content

Commit

Permalink
fix(core): NativeFileService, should check file type on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Jul 8, 2022
1 parent fe48fc6 commit d07c568
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,12 @@ const createNativeFileService = ({
await fsModule.FileSystem.fetch(options.fileUrl, { path: downloadPath });

const fileType = getFileType(getFileExtension(options.fileUrl));
const dirType = {
'file': 'downloads',
'audio': 'audio',
'image': 'images',
'video': 'video',
} as const;

if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' && fileType.match(/audio|video/)) {
await mediaLibraryModule.save(downloadPath);
}
if (Platform.OS === 'android') {
const dirType = { 'file': 'downloads', 'audio': 'audio', 'image': 'images', 'video': 'video' } as const;
await fsModule.FileSystem.cpExternal(downloadPath, options.fileName, dirType[fileType]);
}
return downloadPath;
Expand Down

0 comments on commit d07c568

Please sign in to comment.