3

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.

 

6 replies

null
    • Rafael Sanchis
    • Rafael_Sanchis
    • 3 mths ago
    • Reported - view

    to understand this better Mel

    removeFle(Image)  remove all images (Covers) from server ? I Create it with sharelink.

      • Fred
      • 3 mths ago
      • Reported - view

      I like the Spotify link. Do you update the link manually or does Spotify have an api that you can use to search their inventory?

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

       Hola Fred 😔 don't know how do it via API.

      • Mel_Charles
      • 3 mths ago
      • Reported - view

       Ninox's filing handling was pretty poor in that you could (so you thought) delete a file in your app as far as an image was concerned but ite actual file still sat on their servers. removeFile is their function to address this. thus. removeFile delete one file at a time unless you construct a loop in your script(s) to delete more files. Ref re server = means Ninox's server.

      removeFile only acts upon the stored file it self - so you can delete the file itself but still have the link reference. Hence the need to flush the image cell to null afterwards to remove the reference.

      I only referred to an image file cell within a record but you can use this on Pdf files etc attached to records etc ie removeFile(this, "pricelist.pdf")

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

      Excelent explained. Thanks.

      • Mel_Charles
      • 3 mths ago
      • Reported - view

       De nada

Content aside

  • 3 Likes
  • 3 mths agoLast active
  • 6Replies
  • 61Views
  • 3 Following