How do I send additional data with File

1 Answer 799 Views
Upload Window
John
Top achievements
Rank 1
Iron
Iron
John asked on 18 Jun 2021, 08:29 PM

I have a Blazor server app which I am using to upload photos.  I am attempting to use the Window and Upload components to have a modal dialog.

It is unclear to me from the examples WHEN does the Upload component attempt to call the API Controller.  Also, I need to specify exactly where to place the uploaded picture.  I have a special folder off the root for photos and folders within that to "group" the photos.

How do I pass the "group" to the controller from the Upload component?

Eventually, this app will be used on tablets and phones and I will want to upload from the device storage OR from the camera.  I don't see anything related to that.

1 Answer, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 19 Jun 2021, 05:35 PM

Hello John,

To each distinct question I see:

  • When the API controller is called - by default, as soon as the user selects the file. You can make that happen on a click of a button by setting the AutoUpload parameter to false.
  • Where to store the files - this is entirely up to the controller code. It defines what to do with the files and where to save them.
  • How to pass the group to the controller - you can add metadata to the files through the OnUpload event (see the second sample).
  • Touch devices with a camera - once the user taps the Select button their browser will show the native OS file selection options, and camera-enabled systems should have a camera option there. This is OS dependent and also depends on the permissions their browser has been granted, and is not something the web app can control.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

John
Top achievements
Rank 1
Iron
Iron
commented on 20 Jun 2021, 08:34 PM | edited

I may have been slightly unclear in my description of "grouping". I have a base folder wwwroot\ClientImages to which I want to upload a file. However, I want to upload the file to a subfolder of ClientImages to be determined at the time the file is selected. i.e. I pick a folder ("Fathers Day 2021") from a dropdown and the file(s) I select should go to that folder. I want to send the folder selection along with the file(s).
Svetoslav Dimitrov
Telerik team
commented on 23 Jun 2021, 02:08 PM

Hello John, 

The Telerik UI for Blazor Upload component provides a "connection" between the UI of the application and the backend. It sends the file to the controller/API and the latter control where the file will be actually saved. 

If I misunderstood the question, could you provide some more details on what behavior you are expecting from the component.

John
Top achievements
Rank 1
Iron
Iron
commented on 26 Jun 2021, 10:55 PM

All good. After checking out the link for OnUpload event, it gave me ideas and they worked.
Tags
Upload Window
Asked by
John
Top achievements
Rank 1
Iron
Iron
Answers by
Marin Bratanov
Telerik team
Share this question
or