X
Xata11mo ago
Kaligraphy

Hi,

Hi, How do i delete a file from a record? When I delete the file from Xata app UI, and i refresh the page, the file reappears. I was testing a feature to update images on a Nextjs app and at first, I thought maybe it was Nextjs aggressive caching behavior but replacing the current file in the record with ANY file works both on the Nexjs app and Xata UI (I have no problem with that) but trying to delete it both from Xata's UI and my app fails.
5 Replies
Kaligraphy
KaligraphyOP11mo ago
kostas
kostas11mo ago
Thanks for the report. I can reproduce this, we will look into it. It only happens with file arrays right? ("Allow multiple files" option) I think it is strictly a UI problem, deleting files from the SDK seems to work. Both SDK methods work well in my tests. Delete files by updating a record: https://xata.io/docs/sdk/file-attachments#delete-a-file-from-an-array-through-updating-a-record
await xata.db.mytable.update('rec_cncss9lqem622f7ucbg0', { filearraycolumn: [] });
await xata.db.mytable.update('rec_cncss9lqem622f7ucbg0', { filearraycolumn: [] });
Deleting files from array using the files API: https://xata.io/docs/sdk/file-attachments#delete-a-file-from-an-array-using-file-apis:
await xata.files.delete({
table: "mytable",
column: "filearraycolumn",
record: "rec_cncss9lqem622f7ucbg0",
fileId: "epbki80eu11792hi6e6eobp8oo",
});
await xata.files.delete({
table: "mytable",
column: "filearraycolumn",
record: "rec_cncss9lqem622f7ucbg0",
fileId: "epbki80eu11792hi6e6eobp8oo",
});
Let me know if you encounter issues with the SDK, some code examples would help. Meantime, we are looking into the Web UI issue. Also note the issue is specific to deleting the last file from a file array. If you have multiple files in it you can delete all but the last one. We also noticed that changing the Access url from Private to Public or the other way around isn't responding. We'll fix these items as soon as possible. If you notice anything else acting up please shout. And just to avoid confusion - after deleting a file, its urls remain active and valid for our CDN's cache duration of 4 hours.
Kaligraphy
KaligraphyOP11mo ago
I noticed that, but base64Content was undefined from the SDK which signifies that the file is gone I take a look at it again
kostas
kostas10mo ago
These issues should be resolved now! We've deployed a fix. Let us know if you encounter any problems, although things should work well.
Kaligraphy
KaligraphyOP10mo ago
will do
Want results from more Discord servers?
Add your server