This is a migrated thread and some comments may be shown as answers.

Uploading xml file that only exists in memory

1 Answer 42 Views
This is a migrated thread and some comments may be shown as answers.
Neal Robben
Top achievements
Rank 1
Neal Robben asked on 23 Mar 2010, 02:52 PM

I have the following situation:

A homemade upload-window that contains a RadUpload control (for uploading videofiles) and some textboxes for entering meta-data about the files.

Now I have the following usage-scenarion:
- User opens window
- User uses RadUpload to select "Video1.mpg"
- User presses RadUpload's upload button and "Video1.mpg" is uploaded to the server
- User enters meta-data for the file (Description, Category-tags)...
- Users presses "Upload meta-data"
- Program constructs XML-object in memory. This object contains the meta-data
- Program uploads the content of this XML-object to the server where it is stored as a file ("Video1.mpg.metadata") in the same folder as the file "Video1.mpg"

Is there an elegant way to do this using RadUpload? For each video-file that was (successfully) uploaded, I need to programmatically start another upload (SEPARATE from the upload that handles the video-file!!!) that uploads the contents of an XML-object to a file on the server.

Does anyone have an example of this?

I figured I could use the following code:
metaFileUploader.CurrentSession.SelectedFiles.Add(new RaduploadSelectedFile(xxx));

The problem is that the constructor for RaduploadSelectedFile only takes a FileInfo object (Which in turn only takes a string pointing to a file). So there is no way to get the data from memory.

I have also read an article on here that stated how to upload a bytestream by handling the FileUploadStarting event and initializing the NewFileStream property (of the FileUploadStartingEventArgs) with a custom stream.

I don't think this is a solution because there is no FileUploadStarting event happening that I can react to because I have to add the files from memory and then start the upload.

I have a feeling that both of these suggestions could offer part of the solution, but I can't put it all together.

    Kind Regards,

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Mar 2010, 09:59 AM
Hi Neal,

Thank you for contacting us.

Current release of RadUpload can send extra information for each of uploaded files. We named this information "Custom Parameters". More information about them you can find in the Passing custom params to the server side handler article. Please note to send a custom parameter(s) you need a file to upload too, i.e. you will not be able to upload only your custom parameter.

Because of this it will be a good practice to enter all the meta-info first and later to upload it together with the related file. Here are two approaches:
  1. Upload a single file.
    This scenario is very simple and we highly suggest that you should try it first.
    • Set the IsMultiselect property (of RadUpload) to False.
    • Handle the FileUploadStarting event.
    • Inside the event handler attach the meta-info to the current upload.
  2. Upload multiple files.
    This scenario involves customization of the RadUploadItem's Template. Even more you should implement a mechanism to search the elements' visual tree for your meta-info fields. This method requires a lot of development effort. More about it you can find in this forum thread.

    We hope this information will help you to find the right solution for your task. However if you have more questions please drop us a line.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Asked by
    Neal Robben
    Top achievements
    Rank 1
    Answers by
    Telerik team
    Share this question