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

File constructor parameters order are wrong on android? #252

Closed
HarelM opened this issue Sep 10, 2018 · 5 comments
Closed

File constructor parameters order are wrong on android? #252

HarelM opened this issue Sep 10, 2018 · 5 comments

Comments

@HarelM
Copy link

HarelM commented Sep 10, 2018

I have the following code:

let blobToSave = this.nonAngularObjectsFactory.b64ToBlob(responseData, "application/octet-stream");
let file = new File([blobToSave], route.name + ".gpx");
console.log(file);

Which basically gets a base64 string from the server, converts it to blob and creates a file from it.
Here is the output of the console in the browsers:
image
And here is the output of the console when running on an android simulator:
image
Am I doing something wrong?
Looks like the name is the first parameter (the blob)...?

@rpanadero
Copy link

Same issue here. Is there a workaround to avoid this ?

Thanks in advance

@HarelM
Copy link
Author

HarelM commented Nov 5, 2018

I have migrated to use blobs in most part of my code and just use File when I know I'm running a code on a device and not in the browser. But it's a hack...

@rpanadero
Copy link

Ok, I will try to do the same, thank you @HarelM . In my case I think that it is a little bit more complicated as I'm using other third party libraries which could be affected for this issue. For example, this library, https://github.com/digitalascetic/ngx-pica, internally generates compressed files which are built wrongly due to this issue (I guess) and I think that it is complicate to deal with this unexpected behavior.

@HarelM
Copy link
Author

HarelM commented Nov 5, 2018

@rpanadero I agree this is a problem and it should be fixed, IMHO, this is why I reported it.
I tried to use ngx-pica but it had horrible performance so I ended up writing some code to compress images on my own (taken from SO), so I didn't need it, most libraries I use do not use files so I was in luck...
Relevant code can be found here:
https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.Web/sources/application/services/image-resize.service.ts it uses File but this is because File derives from Blob.

@breautek
Copy link
Contributor

File is not what you think it is. Due to some old decisions... it's actually a cordova object, not browser File API.

This issue is tracked at #316 so I'll be closing this issue.

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants