Deleting Images from the app and the server! (update)
I am going to rework all my "Image File Handling" - Scripts
Although these all work okay - we now have a Ninox approach with a new Function that has been introduced in the last main update called removeFile
Many users will recall that deleting images out of apps did not necessarily delete them from the server.
Simply applying Imagefield := " " or null in a script only removed the text reference and tended to left one with orphaned files on the server. To this end, like other users, I have in place various "management" scripts that wade through my records deleting old/unwanted images and then deleting them from the server. With scripts directly on a record that deleted 1, 2 or more images + paperclip or globally based that work on all records. Removing the files is easy enough but to ensure there were deleted from the server requires use of the API key as shown by just one of my scripts below.
So the aim of removeFile is to do both jobs at once - remove the file out of the app and ensure it it is removed from the server. This function removes the the inconvenient API constructs.
See the Documentation here
https://docs.ninox.com/de/skripten/funktionen-uberblick/funktionen/removefile
Note once you remove the file you will still need the flush the field etc to null
removeFile (Image);
Image := null
You need to have the null line in to ensure the text reference is cleared form the image cell as removFile only deals with the action on the file itself itself.
Note of warning, Although this operation works - if you have auto or manual backups that rely on the original image file/position then that placeholder in the backup will still exist and that image will remain on the server. Obviously, if you screw up deleting a load of images in error (and who hasn't!) then you want to be able recover from that disaster.
What the above addresses is to stop all those orphans files and should make it easier to script a deletion routine and stop further bloating your user storage space!. So if you really want the files gone on the server you have to make sure any backups that are also linked to them are removed too!
So process script and kill the images - If okay then perform a new backup then kill all the other backsups that had a reference to the files
other newbies !
fieldId to return the internal ID of a field.
set to dynamically update the value of a field.
Can be used together with get.
renameFile to rename a file.
6 replies
-
to understand this better Mel
removeFle(Image) remove all images (Covers) from server ? I Create it with sharelink.
Content aside
-
3
Likes
- 2 wk agoLast active
- 6Replies
- 50Views
-
3
Following