How to solve local caching? - reactjs

My question is the next:
Situation:
I have an ImagesScreen where I can upload some additional photos, delete them, etc.
When someone add a new photo (from the gallery, react-native-image-crop), I want to make a copy from the image, save it to the local storage (so even if someone delete the image from the gallery I got my own copy in my local storage).
Why:
I do not want to immediately send the photos toward the API, I just want to backup them every day, so when I make a copy from the selected photo(s) I want to retrieve the uri of the local stored image. (not the uri of the image in the gallery)
How would you guys handle this case?

its complicated, try https://github.com/itinance/react-native-fs, is suitable for you.
there you can handle cached dirs, tmp dirs, delete files/save files

Related

Upload a temporary image on AngularJS

I want to simply upload an image so I have a path that links to it temporarily (not the user's local route), that way I will send that path to the backend and there it will be saved on a database. Since it is only for a few seconds until the backend saves it permanently, I want it to be deleted afterwards.
I've been trying with fileReader but so far I have no clue on how to achieve this.

How should images be saved using express? Database, or just file?

I am using basically the mean stack. I'm also using multer but I am trying to see what the best practices are. Using Angular I can upload photos fine and they are going to a folder on my file system. From here I can just view them. However I'm wondering what the best practices are. Should I save the image url to a database along with the size and other properties or should I just pull them from the client? I've seen some solutions but they were from about 2 years ago so I wanted to make sure I'm current.
I have used ng-file-upload upload on the angular part and Multer on the node.js part to handle images for my system.
The method is appropriate and you can go ahead without any doubt.
Most of the websites on the internet follow the same method, they save the images in the file disk system and then they save it's url in the respective database.
Using multer you can have all information required for a photo and the module is really flexible with a lot many options.
I think you should go ahead with what you have in mind. Best of luck.
You just save the image url from the directory, where image is stored. If you need any information, you can get the information from the image where image is stored (Get image from url). So just save image url into database.

Convert image on url to a file without saving?

I have about 300 people wanting to view loads of images at a time but its not possible to download all the images to file. So i need a way where you can use a web url ("http://capes.reflexpro.co.uk/?user=" + p_177166_1_.getName()) to get the image to a path (string) without downloading.
Thx appreciate it
In order to view an image conventionally (i.e. through a web browser, image viewer, etc), you need to have a local copy of the image.
The image initially only exists at the URL you specify, or in other words, it exists only as a file on a remote machine. In order to view it, you need to download it to a directory on the client (i.e. local) machine. This is where the URL gets "converted" into a pathname - the pathname points to the local copy of the remote image. You can think of the URL as a path to the image as well - that URL string points to where the image is.
The reason we need to download a local copy of the image is because most images are stored in a compressed format (JPEG, PNG, TIFF). These need to be decompressed in order to figure out what color each pixel is. It's not efficient to do that on the remote server, so we transfer the compressed image, store it locally, decompress it, then display it. I have to imagine that most, if not all, web browsers will actually store the image on the local disk, partly to cache the image to ensure fast loading times for subsequent views of the same webpage, and partly to minimize RAM usage.

Whats the best file location to download content to?

I am building a WPF application and while im not a newbie, I am not an expert either. My WPF application streams images from a website when connected to the internet. If a user selects the image, I would like to save it to the hard drive. The user would then reuse the image later on when loading the application if it isn't connected to the internet. I will be querying a folder to see if its there in a saved location as well.
I question where the best location is to save it? I think it might be document settings and then application data, but Im not too sure.
Thank you in advance.
For behind the scenes data i usually use the local app data, you can get the directory like this (in case you did not know):
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
I create some root folder there for the application to store the data in, cleanup can then just be done by getting rid of the whole folder.

Drupal renaming files already in system

I've added quite a few images into the drupal system.
Now I've had to rename them.
I've renamed all the images and added them into the default/files folder and ran a script to update all of the files names within the file_managed table. This is both in the filename and uri.
However the changes are visible within admin portion of the site but not the front end.
If I go into the admin and to that content item and do nothing apart from save it, the changes are thn visible on the front end.
Any help with what I need to do to force it would be great.
Try clearing the cache for the entire site at admin/config/development/performance

Resources