I am using the library flutter_cached_pdfview. I am using PDF().fromUrl instead of PDF().cachedFromUrl, and expecting that PDF().fromUrl will never cache the file. I want to download the file everytime because the PDF is constantly changing on the server. How to force PDF().fromUrl to re-download the file everytime.
Related
I am using dio and path_provider to save pdf from url, I am going to show that pdf to user using open_file. But I have problem with saving path.
Where I can save file temporary, show that file, and after some time or when user will not look at the app delete file? File can be even deleted after 2 days. Time when pdf will be removed is not that important.
It can be even longer time, but sooner or later it must happen. This is in order to not have old pdf's stored on the phone in case of pdf's change on the web
Right now it is my path:
var tempDir = await getTemporaryDirectory();
String fullPath = "${tempDir.path}/test.pdf";
edit: there is also a second option, to check if something is in this place saved, if yes, then remove it and download again, but this place can not be shown to a users, I found "getApplicationDocumentsDirectory", this allows me to save pdf in place where users can not read a pdf.
After that reaserch my question will be, If I download my pdf in a way as you can see above it will stay in that place and will never be moved? Now I need to only creade a methode that will see if my pdf is there end will remove it? How to extract name of my pdf I will need that?
I guess you have selected the right path if you just needed to delete the file for the space on device because when you use the getTemporaryDirectory() the system will automatically delete files in this directory as disk space is needed elsewhere on the device. The system will always delete older files first, based on the lastModifiedTime.
But if you want to check if the file changed or not you can send in the response of the file a flag that contains the last updated date and this value can be the file name prefix, so when ever you open the app you can check if the date has changed you will delete the old one manually and store the new one.
If you follow this solution it will be no need to use getTemporaryDirectory() you have to use the getApplicationDocumentsDirectory()
I'm trying to load/open/preview the files within the app but I don't want them to download and be saved in the file system to open them on MacCatalyst. I tried using QuickLook/QLPreviewController but it only works for files already stored in the File system.
I'm fairly new to MacCatalyst, any help is appreciated.
My application is generating excel and pdf reports. They are generated in Uint8list.
Is there a way to open such files in default application?
I tried open_file package, however, it requires a file path while my file is in memory.
same with url_launcher.
Also I tried saving the file then using open_file, but it doesn't work on web as file can't be saved.
I solved the issue by using printing.dat package. it has a PdfPreview that takes Uin8list and shows a preview with so many other options.
I want to save a download a video, save it into a temporary file that will automatically disappear when the app is closed. Is there a convenient way to do so in Flutter?
I'm aware that we can use path_provider package to generate a file in temporary folder, but that file will not disappear after user close the app.
try flutter_cache_manager, you can download the file in cache and remove it from cache:
getFileStream(url) returns a stream with the first result being the cached file and later optionally the downloaded file.
getFileStream(url, withProgress: true) when you set withProgress on true, this stream will also emit DownloadProgress when the file is not found in the cache.
downloadFile(url) directly downloads from the web.
getFileFromCache only retrieves from cache and returns no file when the file is not in the cache.
putFile gives the option to put a new file into the cache without downloading it.
removeFile removes a file from the cache.
emptyCache removes all files from the cache.
If you want to save anything in Flutter, i think key-value storing is the best way to do. In Flutter there is a package called shared_preferences which is help you to store key-value data on disc.
I copied the official websites of the shared_preferences package. On these websites you can read a lot about this.
https://flutter.dev/docs/cookbook/persistence/key-value
https://pub.dev/packages/shared_preferences
I'm trying to automate website testing using powershell. I need to compare one of the images in tag with a file on my hard drive.
Is there a way to access the file without downloading the file the second time?
.. if it's not..
Is there a way to force the browser object (ie9) to get the site without images (without changing it in the settings of the browser) and then download the images individually?