Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated extension when using saveAs with MimeType.other on iOS #65

Closed
RobertOdrowaz opened this issue Jun 18, 2023 · 1 comment
Closed

Comments

@RobertOdrowaz
Copy link
Contributor

When using saveAs to save file of MimeType.other on iOS the created file has repeated extension eg. test.xyz.xyz. This behaviour is a result of extension being appended to file name twice:
First in dart code (file_saver.dart):

name: mimeType == MimeType.other
    ? '$name${Helpers.getExtension(extension: ext)}'
    : name,

Second in native code (Dialog.swift):

let fileURL = NSURL.fileURL(withPathComponents: [temp, fileName+"."+ext])

It seems appending extension in the swift code has been introduced to resolve the issue #20.

I believe the correct solution would be to append extension only in the platform code for both android and iOS (alternatively it could be always added on the dart side but I haven't looked into the implications for saveFile method and other platforms). Currently for mime types different than other extension is never added on the android. It seems it's not strictly necessary because android adds appropriate extension based on the mimeType. However I think extension should be included in the EXTRA_TITLE argument as seen in the example here https://developer.android.com/training/data-storage/shared/documents-files#create-file.

@incrediblezayed
Copy link
Owner

Merged the request and published, thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants