Garbage Collection

I have developed a page which uses Code to edit entries in a Collection.

This includes uploading images into a field in the Collection.

These images are given a very long/obscure URL and do not appear in the Site Editor image store.

My question is - what happens to the image storage used when the row in the Collection is deleted?

I hope it is automatically ‘garbage collected’! I don’t want to find that I run out of space after years of operation!!

Thank-You

the code to upload the image is:
export function saveButton_click_1(event) {
if ($w(“#myUploadButton”).value.length > 0) { // user chose a file
//console.log(Uploading '${$w("#myUploadButton").value[0].name}');
$w(“#myUploadButton”).startUpload()
.then( (uploadedFile) => {
//console.log(“Upload successful. File is available here:”);
//console.log(uploadedFile.url);
$w(“#image1”).src = uploadedFile.url;
let toSave = {
title: $w(“#StockNumber”).value,
image: $w(“#image1”).src,
description: $w(“#Description”).value ,
price: $w(“#Price”).value,
sold: $w(“#Sold”).value ,
new : $w(“#NewIn”).value ,
stock: $w(“#Stock”).value
};

wixData.save(“Stock”, toSave)
} )
. catch ( (uploadError) => {
console.log(File upload error: ${uploadError.errorCode});
console.log(uploadError.errorDescription);
} );
}

}

Hey,
The image URL is saved in a collection, and not in the Media Manager . Therefore, when deleting a row in a collection, it is removed from the collection and not saved in the Media Manager.

I hope it’s clear.

Best,
Tal.

The URL is just a ‘pointer’ and yes indeed when a row is deleted the image url is deleted - I want to confirm that the image itself is deleted, and does not remain in my wix site memory storage.

Thank-you

Hey! As you noticed, in collection we only store URLs to Images. In order to actually delete uploaded image, you’d need to go to Wix Media Manager and delete it from there.

@adas-bradauskas Afas, you cannot do what you suggested IFF user_who_uploads != site admin.
I reported this bug/feature a year ago and it still is not solved. Images do NOT appear in Media Manager, nor in the “Files” option of the Image component in edit mode.
So @dhrh has a valid question, I believe.

Hello Adas

I am uploading images in a Page using the wix explicit ‘upload image’ button

export function saveButton_click_1(event) { if ($w(" #myUploadButton “).value.length > 0) {
// user chose a file
//console.log(Uploading '${$w(" [#myUploadButton](https://www.wix.com/code/home/forum/search/posts%3Fquery=.num.myUploadButton) ").value[0].name}'); $w(” #myUploadButton “).startUpload()
.then( (uploadedFile) => {
//console.log(“Upload successful. File is available here:”);
//console.log(uploadedFile.url);
$w(” #image1 “).src = uploadedFile.url;
let toSave = {
title: $w(” #StockNumber “).value,
image: $w(” #image1 “).src,
description: $w(” #Description “).value ,
price: $w(” #Price “).value,
sold: $w(” #Sold “).value ,
new : $w(” #NewIn “).value ,
stock: $w(” #Stock ").value };
wixData.save (“Stock”, toSave) } )
. catch ( (uploadError) => {
console.log(File upload error: ${uploadError.errorCode});
console.log(uploadError.errorDescription); } ); } }

This image is not stored in the Media Manager (or more accurately - I can not find it there!)

However, whilst I can use this Page to update/edit records in my Collection in Preview mode it
does NOT update the Collection if I use it in my Published Site. I have checked Permissions -
which are all set to Anyone.

So I appear to have two problems - garbage collection on my uploaded images, and with
wixData.save("Stock’, toSave) only seems to work in Preview Mode.

Help required - this is a major, major issue for me

David

@giri-zano

Interesting, thank-you - a bit of a disaster to say the least!

I don’t understand your comment “IFF user_who_uploads != site admin” - I am the site owner and whilst I can upload images and edit the Collection in Preview mode - I cannot do it in the Published site!

Is Site admin not the same as site owner?

@dhrh You can actually edit live data through Dashboard, there’s a dedicate section “Database”. In it, you can access Media Manager and delete unnecessary images there. But I agree that it’s not ideal for your use case.