Provide file's thumbnail from a different file - thumbnails

I've been trying to save the thumbnails for the files separately, so that when the OS will call ReadFile() to load the thumbnail, it will be loaded from an additional file, instead of the original file.
My question is if this is even possible. Can I recognize when the OS is requesting the thumbnail (between all the ReadFile() calls that it makes, with different offsets and buffer sizes) and deliver it from a different file?
Also, can I disable the requests for a thumbnail and deliver it in a different manner, instead? I want to reduce the number of ReadFile() calls that the OS makes for a file and just receive ReadFile() requests when I actually open the file.
Thanks!

It is not the OS that requests thumbnails but Explorer, which is just a regular application. Explorer can open files for many purposes and there's no good way to distinguish when it reads thumbnails or any other metainformation. Neither there's a way to turn off tumbnails for a specific drive.

Related

Providing EXIF-free images in a gallery or other webpage

First, thanks for any and all help regarding this topic.
Sites like Facebook and Twitter strip EXIF information from images as they are uploading. My goal is to allow users to upload images to our platform (working with Nextcloud and others) with full EXIF information, however, we need to display images that do not contain EXIF information or any metadata. Without stripping and creating a second, Exif-Free image for each, is it possible to simply hide that EXIF info so that, if a user downloads that image, the EXIF is not embedded?
We were told that the only way to do this is to have a second, exif-free copy (the order of when that's created is irrelevant pre/during/post upload). I'm hoping there's a way that we can simply display such a copy without doubling our physical space requirements.
Thanks again for your help.
Exif is metadata, along with IPTC, XMP, AFCP, ICC, FPXR, MPF, JPS and a comment, just for the JFIF/JPEG file format alone. Other picture file formats support even more/other metadata.
You wrote it yourself: a download - so it's a file in any case. Pictures are files, just like executables, movies, texts, music and archives are files, too. And metadata is part of its content, so whoever accesses the raw bytes of the file can grab everything in it. Which is not "please don't look" proof. If you
create that on the fly by stripping metadata everytime a download is requested,
or if you do it once to preserve performance and instead occupy space remains your decision.
If there would be something as simple as a "don't show" feature then it would still be in the file and could be extracted easily by software written to ignore that instruction. Seriously, there's no shortcut to that - do it properly and don't spare yourself from getting work done at the wrong end.

Do we need to manually delete the recorded cached video file using ImagePicker flutter plugin?

I am using the ImagePicker (https://pub.dev/packages/image_picker) plugin to record videos and I noticed the recorded videos are stored in app's cache folder (example: /data/user/0/com.example.app/cache/999b6a18-114b-4fd3-b089-09ce4574bf765726458033916036262.mp4")
In the plugin docs it says
Note: Images and videos picked using the camera are saved to your application's local cache, and should therefore be expected to only be around temporarily. If you require your picked image to be stored permanently, it is your responsibility to move it to a more permanent location.
Here's what I am wondering about:
How long will the files remain in the cache folder? (I am concerned on too many video files being accumulated)
What is the mechanism on the cache data? does the Android/IOs system has some limitations on the size of the cache folder?
If there is some sort of limitations, what will happen if users record more videos will the system delete the older videos to make room?
Overall would you guys recommend that I delete the recorded cached video immediately after processing it (Example uploading it to my server)?
How long will the files remain in the cache folder?
Usually, cached files remains in the folder until you uninstall the application or when you use a "Clear Cache" option (also works with "File Cleaner" applications). In the case of images fetched from a web API they might contains a Cache-Control header which will help to define directives to invalidate them from the cache.
Sometimes, a different behavior can occur on Android phones depending of the software overlay, for example Honor software (EMUI) is known for clearing cached files by itself from time to time, but it does not seem like the exact duration is mentioned anywhere.
Does the Android/iOS system has some limitations on the size of the cache folder?
The cache folder does not have a size limitation, it will grow as big as needed (or until your phone runs out of available space), this is why people tends to recommend clearing the cache of certain applications manually when it becomes too big.

File Uploading in Sakai

I want to know if there is a 'right' way to make file uploads through custom tools.
I've seen the https://confluence.sakaiproject.org/display/BOOT/File+Uploads+with+RSF guide and it seens ok, but It stops with the file in memory with no further info. I can built a random file upload code but I want to make it Sakai-friendly (Using ContentHosting and Resources service?)
Any hints?
Thanks
The link you provided for the first part is a good example of how to get the upload initially processed. Going through RequestFilter will get your files validated, but you can use whatever method you want to upload it.
For the second part, I'd look at the ContentHosting webservice (createContentItem) for an example of how to add a file from a byte[] in memory after you've uploaded it.
These methods in ContentHostingService also accept InputStream as a parameter as of 2.7 (KNL-325), so you don't have to store the entire file in memory and can stream it as you're uploading, which you should do if the files are of any reasonable size.

How can I save a html file with external resources using AFNetworking?

I would like to save a .html webpage with AFNetworking, but would also like to save the resources (such as .css files, .js files, images etc) within the webpage so that the whole webpage can be viewed offline.
Is this possible with AFNetworking, and how would I do it? Could a short example be posted please?
Thanks!
AFNetworking is not necessary to do this. Instead, what you want to do is use an NSURLCache subclass that supports disk cacheing (such as Peter Steinberger's fork of SDURLCache). With that in place, just load up a URL using a UIWebView (this may not necessarily have to be displayed to a user), and subsequent loads should use that local cache.
At the very least, do not waste your time trying to write something on your own to download assets on a webpage. This process requires a web browser (which UIWebView qualifies as) to determine everything needed to load.

Where to cache remote image files in iOS?

I am planning to cache the images from a server and use show it as a sort slide show in my App. I would be asynchronously loading the images.
I have two options:
Either to cache the images as a File and use it whenever necessary.
Cache the images objects in memory and use it when ever necessary and write it in to files when Application quits.
Which one would be better?
Please let me know if you you have any kind of suggestions regarding caching images.
Your second approach has 2 major flaws:
If there's too many images then your application will get low memory warning and you'll have to dispose your images from memory anyway
It's also not a good idea to save all images to file on application quit - it is not guaranteed that your saving code will finish on application exit (e.g. if it takes too long system may just terminate your app and your images will be lost)
I'd suggest saving images to files right after you download them and keep in memory reasonable number of images you need to show without visible delay (loading extra images when required and disposing of unnecessary ones)
I would recommend you the first option. Leaves you more flexibility, e.g. when the data size increases the memory size.
I'd do it like this: Have a NSMutableDictionary with the cached images (as UIImage objects). If the image is not in the cache, look whether it's available as a file. If it's not available as a file, load it, put it into your dictionary and also write it to a file.
As for where to write the files to: you can either use the NSTemporaryDirectory() or create a directory inside your NSLibraryDirectory (use NSSearchPathForDirectoriesInDomains to locate it). The later has the advantage/disadvantage that it will be in the iTunes backup (whether that's an advantage or not depends on the use case). Using the Library directory is Apple's recommended way of storing data that is backed up but does not appear in the iTune's file exchange thingy (Documents directory).
I have started using EGOImageView to handle my caching; it's very versatile and handles the intricacies of caching for you.
It works very well for pulling images via http, you can find it on the EGO developer website here
http://developers.enormego.com/
For image caching solution on iOS platform, you might want to consider SDWebImage framework available at: https://github.com/rs/SDWebImage. It is very easy to integrate and takes care of all your image caching worries.: read more about the working here: https://github.com/rs/SDWebImage#readme
We recently picked this up for our app and it works great.