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

Upload from Isolated Storage

9 Answers 119 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 14 Mar 2011, 05:04 AM
I don't see anyway possible but wanted to ask just in case.  Is there any way to use RadUpload with files from Isolated Storage or memory stream?  I have a form that will allow the user to upload an image of themselves or to take one via webcam and upload.  I would like to use the same mechanism to handle the upload of the web cam one as I do the regular upload one but can't find a way to attach the file programmatically or just send a memory stream, like:

(Upload Files from Multiple Sources )

http://www.componentone.com/SuperProducts/UploadSilverlight/

Thanks,

Jason

9 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 16 Mar 2011, 05:16 PM
Hello Jason Maronge,

You can achieve this with the RadUpload control. In the FileUploadStarting event, you can change the file stream that will be uploaded through the event args. You can see more information about this here. What you will need to do is to add an item to upload in the RadUpload and then change its file stream to the stream of the isolated storage.

Best wishes,
Alex Fidanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Jason Maronge
Top achievements
Rank 1
answered on 18 Mar 2011, 05:08 AM
Alex,

My question is, does the user have to select a file?  I want to be able to do this without the user selecting anything.  I take a picture of the user through the webcam and want to upload that image.  I have tried to add to the RadUpload.Items collection and call StartUpload but it did not work.  Am I missing something here?

Thanks,

Jason
0
Alex Fidanov
Telerik team
answered on 21 Mar 2011, 09:17 AM
Hello Jason Maronge,

This is correct, you do need to add an item in the RadUpload. However, you need to populate the RadUpload.CurrentSession.SelectedFiles collection with items of type RadUploadSelectedFile. To create one, you need pass a FileInfo object as constructor parameter. This would require elevated permissions and I am not sure if you could do this in procedural code entirely. However, if you have permissions and you can create such file and add it in the mentioned collection, you can call the PrepareSelectedFilesForUpload method of the RadUpload and then invoke StartUpload.

Best wishes,
Alex Fidanov
the Telerik team
0
Jason Maronge
Top achievements
Rank 1
answered on 21 Mar 2011, 02:54 PM
That is what I thought.  What I would like to do is to add a file from IsolatedStorage or FileStream like the one from ComponentOne. 

Jason
0
Petar Mladenov
Telerik team
answered on 24 Mar 2011, 09:41 AM
Hi Jason Maronge,

Currently, there is nothing exposed on the RadUpload to allow this. The control relies on the streams of the FileInfo objects from the selected files in the current session.
However, we created a feature request and you will be soon able to vote for it in our PITS(Upload: Ability to upload a file from Stream or Isolated Storage).

Regards,
Petar Mladenov
the Telerik team
0
hwsoderlund
Top achievements
Rank 1
answered on 31 Mar 2011, 01:15 PM
I just want to say that the feature request is up now and has ID 5247, so please vote for it.
0
Dave Navarro
Top achievements
Rank 2
answered on 30 Nov 2011, 07:50 PM
Hello,

I'm working with RichTextEditor and I wish to export a docx file and save it on the file server.

Could I use this method to save (upload) my docx file? The RichTextEditor 'exports' as a stream and it seems like it might work.

Keep in mind that the user will not select a file. They'll be working with RichTextEditor and then click a button that will save their .docx file on the file server. The "magic happens here..." part is getting the file stream into the upload control so it can be saved on the server.

Any thoughts or suggestions?

Please let me know and thanks,

~ Dave
0
Petar Mladenov
Telerik team
answered on 05 Dec 2011, 07:35 PM
Hello Dave Navarro,

 We tried the following code but we did not succeed to upload the file on the server:

private void Button_Click(object sender, RoutedEventArgs e)
     {
         TxtFormatProvider provider = new TxtFormatProvider();
         SaveFileDialog saveDialog = new SaveFileDialog();
         saveDialog.DefaultExt = ".TXT";
         saveDialog.Filter = "Documents|*.TXT";
         bool? dialogResult = saveDialog.ShowDialog();
         if (dialogResult == true)
         {
             using (Stream output = saveDialog.OpenFile())
             {
                 provider.Export(this.rtb.Document, output);
                 UploadToTheServer(output, saveDialog.SafeFileName);
             }
         }
     }
private void UploadToTheServer(Stream data, string fileName)
       {
           RadUpload upload = new RadUpload();
 
           upload.TargetFolder = "UserUploads";
           RadUploadSelectedFile file = new RadUploadSelectedFile(data, fileName);
           upload.CurrentSession.SelectedFiles.Add(file);
           upload.PrepareSelectedFilesForUpload();
           upload.StartUpload();
       }
We'll keep in touch with you if we manage to find a solution.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dave Navarro
Top achievements
Rank 2
answered on 05 Dec 2011, 08:06 PM
Hello and thanks for the reply.

Here's how I have my code setup (which works);
DocxFormatProvider provider = new DocxFormatProvider();
MemoryStream stream = new MemoryStream();
provider.Export(this.radRichTextBox1.Document, stream);
stream.Position = 0L;
RadUploadSelectedFile f = new RadUploadSelectedFile(stream, app.strBinFilename);
this.radUpload2.TargetFolder = "AppData/Alpha/" + app.strServerName + "/India/November";
this.radUpload2.CurrentSession.SelectedFiles.Add(f);
this.radUpload2.PrepareSelectedFilesForUpload();
this.radUpload2.StartUpload();

Most of this snippet was passed along to me by someone at Telerik support... via a support ticket.

The method works very well so thank you very much for your help.

I hope this information can help someone else in their project too.

~ Dave
Tags
Upload
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Jason Maronge
Top achievements
Rank 1
Petar Mladenov
Telerik team
hwsoderlund
Top achievements
Rank 1
Dave Navarro
Top achievements
Rank 2
Share this question
or