Upload from Isolated Storage

10 posts, 0 answers
  1. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 14 Mar 2011 Link to this post

    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
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 16 Mar 2011 Link to this post

    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!
  3. DevCraft banner
  4. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 18 Mar 2011 Link to this post

    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
  5. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 21 Mar 2011 Link to this post

    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
  6. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 21 Mar 2011 Link to this post

    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
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 Mar 2011 Link to this post

    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
  8. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 31 Mar 2011 Link to this post

    I just want to say that the feature request is up now and has ID 5247, so please vote for it.
  9. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 30 Nov 2011 Link to this post

    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
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 05 Dec 2011 Link to this post

    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 >>

  11. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 05 Dec 2011 Link to this post

    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
Back to Top
DevCraft banner