Please, I need some help from you guys. I am developing a Phonegap application for Android that downloads some PDF files on a file explorer style interface and them open the files on the Adobe Reader application. The app works well on success scenarios, but if for some reason the connection drops during the download and you close and reopen the application, when you click the pdf file's icon, he tries to open the file - I cache the files on the internal storage, I only download if the file doesn't exists - and adobe reader shows a error of corrupted file. Is there a way on Cordova that I can check if a file is corrupted, so I can download it again if it is corrupted?
thank you
Wouldn't it be easier to keep a flag for each of the files you download to indicate that the download has completed? Once the file finished downloading you set a flag for that file. That way if a transfer is interrupted then the flag won't be set and you can treat that case as if the file doesn't exist so that your application doesn't try to open an incomplete file.
Related
I have written an application where on button click a .docx file is generated on the server and returned to client as base64 string. What I want to do now, is to let the user download the file in a directory of their choice.
To demonstrate what I mean, if I instead want to upload a file having a <input type='file'/> opens a dialog such like this
Where I can select the file. Is there any way to open this kind of dialog for a download button? I understand that the web-page doesn't receive the actual path on a clients pc for security reasons, but if you can chose an upload file, there is no reason to not chose a download path right?
No, for security reasons this is not possible.
See:
https://github.com/eligrey/FileSaver.js/issues/42
I have a JS code which should download a file and need to open that corresponding file. I'm able to download it but need a JavaScript code to open the recently downloaded file from any browser.
Answer is No.
Why :
When user download file into his local file system then downloaded file became a part of users file and as you know you can't access any file/directory from users local file system.
Alternative solution :Yes
Download file using XmlHttpRequest (AJAX) into blob object help link
Open file from saved blob object.
in above alternative solution You can also allow use to save file(download file).
Basically the chrome extension I'm making will download an mp3 file, edit the metadata, then download it on the user's machine.
I have the last part done by using chrome.downloads.download() (I'm pretty sure I can download a local path instead of a url).
But, I'm not sure how to download a file like this one into a directory local to the chrome extension (I don't want the user opening the file before it edits the metadata).
Nevermind, I found the answer: Broswer ID3 Writer by egoroof. This literally does everything I need. What an amazing library!
I have been looking for some solutions for this, i got one here - Show PDF file in Android WebView using mozilla pdf.js Android API Level below 19
but then here he tries to open a local file, is there a way I can open files placed on my server.
You must enable CORS on your server http://enable-cors.org/server.html After that pdf.js could open file from your server as well as local file. Another way is to download file from server and open it locally.
If a pdf reader is not installed in the browser ,from a web page how to make a user install pdf reader on the page load with pdf.
Can not be done in JavaScript. If the browsers allowed sites to install pdf viewers, what next? It would be a security nightmare.
You can not, and should not, make your users install anything. Indicate that the file requires a pdf viewer to view the document -- even a few links to free viewers -- and leave it at that.
You can't do this in JavaScript, the browser will prompt the user to download the .pdf file if a reader isn't present (since it doesn't know what else to do with it), but installing any plugin is outside the purview of JavaScript - and should be - it would be a security nightmare.
What would you make them install, Adobe? :)