Hello,
I have stored uploaded files in the database, with columns: GUID, Name, Size.
The name of the file is not unique. How can I perform remove action with GUID?
Files are prepared from controller with List<UploaderUploadedFiles>, but there is no suitable property to store GUID and pass it to the client side.
I need to call something similar to /RemoveFile?fileId=GUID to delete uploaded file.
Hi Jiri,
Greetings ……!
Yes we can send additional parameters using ‘Uploading’ event arguments of the File uploader component , And then receive it in server . Please refer to the below documentation for reference.
Thanks,
Deepak R.
Hi, thank you for your reply, but I need to pass custom value from server side to the client.
You describe this scenario in links below, but I don't see any way there, how I can pass custom value (database GUID in my case).
https://ej2.syncfusion.com/aspnetmvc/Uploader/PreloadFiles#/bootstrap5
https://ej2.syncfusion.com/aspnetmvc/documentation/uploader/async#preload-files
Hi, do you have some solution for my issue? I read documentation but I can't find nothing. Thank you.
In order to call the remove action using a Guid parameter, you will need to use the Guid.Parse() method to convert the Guid string to a Guid object. Then you can use the Remove() method to remove the item with the specified Guid from the collection.
Here is an example code snippet that demonstrates how to call the remove action with a Guid parameter:
java
Copy code
// Assume the following list of items with GUIDs
List<Item> items = new List<Item>()
{
new Item { Id = Guid.NewGuid(), Name = "Item 1" },
new Item { Id = Guid.NewGuid(), Name = "Item 2" },
new Item { Id = Guid.NewGuid(), Name = "Item 3" },
};
// Assume we want to remove the item with this GUID
string guidString = "a7595ee5-96ce-4fc1-a2fc-4e4c4ba4e0b7";
// Parse the GUID string to a Guid object
Guid guidToRemove = Guid.Parse(guidString);
// Call the remove action using the Guid parameter
items.Remove(items.FirstOrDefault(i => i.Id == guidToRemove));
In this example, we first define a list of Item objects with unique Guid identifiers. We then define a string variable that represents the Guid of the item we want to remove. We use the Guid.Parse() method to convert the string to a Guid object. Finally, we call the Remove() method using the FirstOrDefault() method to find the first item in the list that matches the Guid we want to remove.
Hi, thank you for your reply, but you probably don't read my question thoroughly. My question is not about removing items from colletion. I want to know, how to pass custom value to preloaded files in the uploader component (guid in my case).
Hi, can I ask you for answer? It's possible to solve my issue or not. If not, do you plan add suport for that?
Thank you.
Jirí, we cannot send the additional data to the preload files because preload files property has only the Name, Size, and Type properties.
To know more about the preload files property, please refer to the documentation: https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Inputs.UploaderUploadedFiles.html
Hi, yes I read this part of documentation, so it was the reason to create this thread. I hoped that you have some workaround to this, because saving data to database, where name of file is not unique is common thing. So now is impossible to preload this data back to component, what is a little annoying. I think & hope that it could be useful feature for some next component update.
Hi Jiri,
Upon reviewing your request, we would like to inform you that Uploader pre-uploaded files are specifically intended for display purposes within the user interface (UI). However, we regret to inform you that we are unable to provide additional data for pre-uploaded files. Additionally, the server call functionality is not available for pre-uploaded files. We apologize for any inconvenience this may cause.
Regards,
Priyanka K