mostafa-mansour1 / previewAnyFile

Cordova Plugin to preview any file in native mode by providing the local or external URL
MIT License
33 stars 31 forks source link

Saving a document on Android device #17

Closed misharysh closed 3 years ago

misharysh commented 3 years ago

I am using latest version of your plugin. I have a specific case when an error occurs. A link is sent to me from the server that does not have an extension. In this case i am using 'previewPath' method. also i have next parameters: mimeType : 'application/pdf', name: 'test.pdf' . When i open this document on Android device the name of it (on the top header ) is without extension and when i click 'download' it saves it as a file without extension. iOS works correctly. And saving works correctly if my url contains extension. Can you check it pls in your side?

mostafa-mansour1 commented 3 years ago

Kindly send me your full code (if also with the real link it will be better)

And i will check it tomorrow

Regards,


Mostafa Mansour Software Engineer 00971 524988466 0020 1113019196

On 15 Feb 2021, at 9:01 PM, misharysh notifications@github.com wrote:



I am using latest version of your plugin. I have a specific case when an error occurs. A link is sent to me from the server that does not have an extension. In this case i am using 'previewPath' method. also i have next parameters: mimeType : 'application/pdf', name: 'test.pdf' . When i open this document on Android device the name of it (on the top header ) is without extension and when i click 'download' it saves it as a file without extension. iOS works correctly. And saving works correctly if my url contains extension. Can you check it pls in your side?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mostafa-mansour1/previewAnyFile/issues/17, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABSFOB3DD5QQBYY44MA2H3LS7FHOZANCNFSM4XVAMM7A.

misharysh commented 3 years ago

var parameters = {}; var docName = doc.Name.replace(/\s/g, '_') + '.pdf'; parameters = {mimeType : 'application/pdf', name: docName};

PreviewAnyFile.previewPath( function(win){ if (win == "SUCCESS") { console.log('success'); }else{ console.log('error');
} }, function(err){ console.log('err',err);
}, doc.doc_url, parameters);

mostafa-mansour1 commented 3 years ago

I see you are trying to use the plugin to download the file to the device of the user, not view it.

The purpose of the plugin is just to preview the file content to the user, when you provide an internet link, android open this link directly

in IOS, we haven't that option so I downloading the content of the file locally then preview it,

I tried to do that in android but I faced extra issues, and it needs extra permission, and the final behavior is the same.

so I don't recommend applying this.

if you need to download the file from the internet, try using an HTTP request or fetch from javascript then you can preview the base64 from our plugin