How do I delete files from the tiny storage server?

I can drag and drop files into the networking example, and when I join from a browser that wasnā€™t there when the files were created it will load files that were previously created correctly. All very cool.

But how do I delete files that were stored in tiny storage when I donā€™t want them anymore? Once they are uploaded I get a callback in beginListenFilespawn engine_networking_files and they get added to the scene right away.

Original Post on Discord

by user 563549194137239552

Answering my own question does it have something to do with ā€˜syncdestroyā€™ ?

by user 563549194137239552

SyncDestroy is used for networking the destroy call on a object in the scene - it will not delete data on the backend server.

You can send an event for removing the file upload event so you will not download the file again when you come back to the room later - but I think thereā€™s no code in engine right now for letting the backend know that you want to delete a file completely

I think the backend has code for it - but I need to check

For removing the event from the backend you can use this.context.connection.sendDeleteRemoteState(<guid>) with the guid of the object that is being spawned. Thatā€™s not ideal but maybe works for the short term?

Iā€™ll try itā€¦ I have syncDestroy working and it deletes for all clients but when they reload the files come back in from the back endā€¦ will let you know how the remote state deletion works

by user 563549194137239552

Ok thanks!

sendDeleteRemoteStateAll works but sendDeleteRemoteState didnā€™tā€¦ maybe I am getting the wrong GUID? I used let guid = (found.object as GameObject).guid ā€¦ itā€™s the same found.object I used syncDestroy on and the syncdestroy seemed to work

by user 563549194137239552

maybe the object i found using raycasting is the child mesh and itā€™s the parent object that is in the remote stateā€¦ will explore

by user 563549194137239552

having trouble figuring out the GUID to use to deleteā€¦ in beginListenFileSpawn if I log the GUID of the gltf file after loading it is different every timeā€¦ should i be using the evt.file_hash that is coming in before the file gets loaded?

by user 563549194137239552

basically i am getting the object to delete by doing a raycastā€¦ syncDelet works when i call it on that objectā€¦ how do i get the GUID to use for the sendDeleteRemoteState call

by user 563549194137239552

Have you tried deleting the guid that you get via context.connection.beginListen(File_Event.File_Spawned, async (evt: FileSpawnModel) => { (evt.guid)

Iā€™ll try that

by user 563549194137239552

I hardcoded a GUID from a console.log of the evt.guid and it worksā€¦ now I just need to figure out how to preserve that info ā€¦ looking at the userData field perhaps

by user 563549194137239552

is there any reason in the beginListenFileSpawn method in engine_networking_files.ts file I canā€™t just set the objects uuid after being created to the evt.guid from the file spawned event? it should be unique right?

by user 563549194137239552

I think that should be no problem - not 100% sure tho. I dont think we use the uuid that threejs generates anywhere

I just added obj.userData[ā€œremote_guidā€] = evt.guid
to it and Iā€™m happy with that

by user 563549194137239552

Sure :slightly_smiling_face:

when i set the uuid to evt.guid it made it not show up on other peoples machine so i will leave that alone

by user 563549194137239552