RadAsyncUpload without temporary file

9 posts, 0 answers
  1. cmh
    cmh avatar
    8 posts
    Member since:
    Apr 2010

    Posted 17 Jul 2013 Link to this post

    I would like to use the RadAsyncUpload control without using a temporary file.  I just need the stream to pass to another function(e.File.InputStream).  How can I accomplish this?  

    It works for me when I run it in Visual Studio, but fails when I deploy it to the server.  I am setting my Temporary Folder to a folder in the HttpContext.Current.Server.MapPath.  The user machine will not have that path.

    My ascx file:
            <telerik:RadAsyncUpload runat="server" ID="RadAsyncUploadLetterFile" AllowedFileExtensions="rtf,rtfb" Width="225px"  
                OnFileUploaded="RadAsyncUploadLetterFile_FileUploaded" MaxFileInputsCount="1" DisablePlugins="True"
                PostbackTriggers="btnUpload" OnClientFileUploadFailed="onClientFileUploadFailed" 
                EnablePermissionsCheck="False" DisableChunkUpload="True" UseApplicationPoolImpersonation="True" 
                Skin="Web20" MultipleFileSelection="Disabled" >
            </telerik:RadAsyncUpload>

    ascx.cs:
            public void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    RadAsyncUploadLetterFile.TemporaryFolder = HttpContext.Current.Server.MapPath(@"..\..\Reports");
                }
            }


  2. cmh
    cmh avatar
    8 posts
    Member since:
    Apr 2010

    Posted 17 Jul 2013 Link to this post

    A little more info:  On the server, it fails on the selection of the file.  It never gets to  OnFileUploaded="RadAsyncUploadLetterFile_FileUploaded".
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 22 Jul 2013 Link to this post

    Hi,

    If you don't want to use temporary files, do not set TemporaryFolder property. The other thing you did correctly is to set DisableChunkUpload to true. Then save uploaded file directly into the Target folder. I'm attaching small sample showing how to do that by using Custom Http Handler.
        protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
        {
            string targetFolder = context.Server.MapPath("~/Reports");
            string fileName = file.GetName();
     
            //Replace this with yours function(file.InputStream)
            file.SaveAs(targetFolder + "/" + fileName);
                        
            return CreateDefaultUploadResult<UploadedFileInfo>(file);
        }
    }

    Regarding your other issue: When project is deployed on IIS it requires to have write permissions to both Temp and Target folders. Verify that your application has the correct permissions.

    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  5. Syed
    Syed avatar
    1 posts
    Member since:
    Mar 2012

    Posted 28 Jul 2013 Link to this post

    Hello,

    I need help on finding a solution on how to handle the exceptions found in the handler's Process method at the client side's OnClientFileUploadFailed event function. Assume we are doing multiple operation in the Process method like saving the file into file system and also into the database. whenever the file operation or the DB operation fails i need to send appropriate action to the client side so that i can display user friendly localized string.

    I tried doing throw new Exception("") but it sends me whole html content along with the message i am trying to send. I want to send one unique number here which will be the ID of the resource string so that at the client side i can pick that localized string based on that resource string ID recieved from the handler in the OnClientFileUploadFailed event function.

    Also is it possible to send the querystring like we send to the handler if we are not using the handler to take those querystring values in the onfileuploaded event?

    Appreciate your help on this.

    Thanks,
    Saleem

  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 31 Jul 2013 Link to this post

    Hi Saleem,

    In handler create custom upload result by using CreateUploadResult<T> method. Then handle the exception and return the custom result. This will pass the values to the client where you will be able to process them. This on-line demo shows how to do that.

    Regarding the seconds question: OnFileUploaded is a server event and there is no problem to read values from the query string. 

    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. Rodrigo
    Rodrigo avatar
    2 posts
    Member since:
    Apr 2014

    Posted 31 Jul 2014 Link to this post

    Hi,

    I'm trying to test the RadAsyncUpload without temporary folders and files. All works fine when using the FileAPI, but when I tested this with IE 9 it doesn't use Silverlight and I can only upload one file at a time.

    I have disabled the chunkupload (set to true), and also removed the temporary folder location.

    Thanks in advance
    Rodrigo
  8. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 05 Aug 2014 Link to this post

    Hi Rodrigo,

    If FileAPI, Flash and Silverlight are not available, the AsyncUpload will use IFrame module. It does not support multi-file selection. http://www.telerik.com/help/aspnet-ajax/asyncupload-multiple-file-upload.html

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. Rodrigo
    Rodrigo avatar
    2 posts
    Member since:
    Apr 2014

    Posted 05 Aug 2014 in reply to Hristo Valyavicharski Link to this post

    Hi Hristo,

    Thanks for you answer. In my scenario Silverlight is available. The only problem is that if a disable the temporary folder and chunck upload the control is using IFrame instead of Silverlight . Is there a way I can disable the temporary folder feature and still use the Silverlight  module?

    Regards,
    Rodrigo
  10. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 08 Aug 2014 Link to this post

    Hello Rodrigo,

    Unfortunatelly this is not posslbe. You can see that mentioned here:
    http://www.telerik.com/help/aspnet-ajax/asyncupload-disable-chunk-upload.html

    Disabling Chunk Uploading will automatically disable Flash and Silverlight plugins.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017