Custom Handler and temp folder.

22 posts, 1 answers
  1. Adam Nelson
    Adam Nelson avatar
    48 posts
    Member since:
    Mar 2008

    Posted 28 Aug 2012 Link to this post

    Documentation states:  

    RadAsyncUpload's file handler can be inherited and extended to support custom functionality, for example, saving images directly to a database, without using temporary folder. 
    (http://www.telerik.com/help/aspnet-ajax/asyncupload-extending-handler.html) 

    I believe I've implemented a custom handler as described in the documentation, but when deployed to a test server running with limited permissions I am seeing: RadAsyncUpload could not create App_Data folder.

    My custom handler writes files directly to the database, am I missing something or is the Temp directory always required for the async upload control?

    I have DisablePlugins="true" and HttpHandlerUrl="~/Handlers/ImageUploadHandler.ashx"

    Please advise.

    Thanks,

    Adam Nelson

  2. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1101 posts

    Posted 30 Aug 2012 Link to this post

    Hi Adam,

    RadAsyncUpload cannot work without a temp directory. However, you can specify which directory it uses with the TemporaryFolder property. When this property is not set, the upload uses the App_Data folder by default.
     
    Regards,
    Bozhidar
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adam Nelson
    Adam Nelson avatar
    48 posts
    Member since:
    Mar 2008

    Posted 30 Aug 2012 Link to this post

    Thank you for the clarification.
  5. Mark
    Mark avatar
    2 posts
    Member since:
    Jul 2012

    Posted 25 Sep 2012 Link to this post

    You might want to update your demo description if that is the case. Here's what it reads now : "RadAsyncUpload's file handler can be inherited and extended to support custom functionality, for example, saving images directly to a database, without using temporary folder."
    To me, this means that I do not need to create a writeable, temporary directory, for the control to use. = BETTER for developers and deployment for those who are saving directly to the DB.
  6. Adam Nelson
    Adam Nelson avatar
    48 posts
    Member since:
    Mar 2008

    Posted 25 Sep 2012 Link to this post

    That's what tripped me up also... the documentation in demos and help seems wrong based on the answer provided here.
  7. Mark
    Mark avatar
    2 posts
    Member since:
    Jul 2012

    Posted 26 Sep 2012 Link to this post

    Just an FYI: I've also added this feature to my web application and was not able to get around the requirement to have a writeable temp directory.
  8. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 28 Sep 2012 Link to this post

    Hi,

     
    Thank you for sharing these documentation issues and for your concern with RadControls and please excuse us for the inconveniences caused by them.

    One important thing that should be added about this scenario is that such behavior ("RadAsyncUpload's file handler can be inherited and extended to support custom functionality, for example, saving images directly to a database, without using temporary folder.") will be possible when the upload of the file is performed in one chunk only. That is why from the upcoming Q3 release we have implemented a DisableChunkUpload property in RadAsyncUpload that will make such behavior achievable again.

    Hope this information will be helpful.

    Greetings,
    Plamen
    the Telerik team
    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 their blog feed now.
  9. Adam Nelson
    Adam Nelson avatar
    48 posts
    Member since:
    Mar 2008

    Posted 28 Sep 2012 Link to this post

    Sounds great. I'll by trying that out when it's released. Thanks for the heads up.
  10. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 04 Dec 2012 Link to this post

    I've just tried this with a custom handler (similar in nature to the demo).

    I have also added the property to disable the chunks:
    <telerik:RadAsyncUpload runat="server"
        MultipleFileSelection="Automatic" MaxFileInputsCount="0"
        PostbackTriggers="rbSave" UploadedFilesRendering="BelowFileInput" OnClientFileUploaded="onClientFileUploaded"
        DisableChunkUpload="true"
        HttpHandlerUrl="~/Classes/Core/Handlers/CustomRadAsyncUploadHandler.ashx" OnClientFileUploadRemoving="fileUploadRemoving" />


    Works great locally.  No temp folders or files are created.

    When I deploy to an IIS server, however, I get the same APP_DATA can't create permission problem that I had before.

    What is going on??

    My handler is pretty simple and I do everything that was suggested in this post +  others regarding this situation and this property.
    Imports Telerik.Web.UI
     
    Public Class CustomRadAsyncUploadHandler
        Inherits AsyncUploadHandler
        Implements System.Web.SessionState.IRequiresSessionState
     
        Protected Overrides Function Process(file As Telerik.Web.UI.UploadedFile, context As System.Web.HttpContext,
                                             configuration As Telerik.Web.UI.IAsyncUploadConfiguration, tempFileName As String) As Telerik.Web.UI.IAsyncUploadResult
            'The BASE process saves things to TEMP location/folder.  We don't want that.
            'Return MyBase.Process(file, context, configuration, tempFileName)
     
            Dim iDocumentID As Int64? = Nothing
            Dim result As CustomRadAsyncUploadResult = Me.CreateDefaultUploadResult(Of CustomRadAsyncUploadResult)(file)
     
            Dim config As CustomRadAsyncUploadConfiguration = TryCast(configuration, CustomRadAsyncUploadConfiguration)
            If config IsNot Nothing Then
                'Save our file to the TEMP area for documents
                SetData.SetDocumentData.SetTempDocument(config.eDocmentCategoryType, file, config.gBatchID, config.eDocumentLocationType, iDocumentID)
                'Then... pass on some vital information for the FileUploaded handler
                result.iDocumentID = iDocumentID
                result.eDocumentLocationType = config.eDocumentLocationType
                result.sAjaxManagerClientID = config.sAjaxManagerClientID
            End If
     
            Return result
     
        End Function
    End Class

  11. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 04 Dec 2012 Link to this post

    I take that back....
    It tries to create the same 2 things locally as well:

    App_Data
        RadUploadTemp
            RadUploadTestFile

    If I'm using the custom handler.
    If I'm not using the BASE process method in the custom handler.
    If I'm DisableChunkUpload=True.
    If my custom handler process uploads directly to the DB.

    WHY does it have a need to have a WRITABLE directory and put this bogus 0kb file out there ???????????

    This goes to part of the point of doing this whole thing to begin with... We don't want to have to setup permissions at the IIS/directory level for something like this.  For example, I do a nightly build that wipes out a directly and lays down my newly built application.  Guess what doesn't work automatically?  The uploads because it mysteriously needs the bogus permission re-attached.

    Can someone from telerik explain this?
    Wasn't the DisableChunkUpload property supposed to take care of this?
  12. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 07 Dec 2012 Link to this post

    Hello Shawn,

    Please excuse us for the inconvenience caused.
    For the Q1.2013 we are going to introduce a property which will enable/disable the check for write permission and it will be used for case such yours.

    In a way of gratitude for pointing this out I updated you Telerik points.

    Regards,
    Peter Filipov
    the Telerik team
    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 their blog feed now.
  13. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 01 Feb 2013 Link to this post

    Hi,

    Testing with the 2013 Q1 Beta...
    Is this property implemented?
    Can't find it...

    Regards
    Caesar
  14. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 01 Feb 2013 Link to this post

    Hi Andreas,

    Could you please set the newly added UseApplicationPoolImpersonation property to true and let us know how it is going?

    Regards,
    Genady Sergeev
    the Telerik team
    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 their blog feed now.
  15. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 01 Feb 2013 Link to this post

    Hi,

    Setting this property doesn't do any difference, it still creates the temp directory...
    We have made a custom handler that saves directly to a database, and we don't need that temp directory.
    The problem is that our web application will be installed on lots of customer environments, and we don't want any file permission problem that could happen with this temp directory.

    We just want the property that Peter Filipov described above, that was to be added in Q1 2013!

    Regards
    Caesar
  16. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 06 Feb 2013 Link to this post

    Hello Andreas,

    Thank you for the explanation. The property to disable the file permission is in the code already and will be available with the upcoming Q1 release. It's name is EnablePermissionsCheck with default value true. You will need to set it to false in order to skip the check.

    Kind regards,
    Genady Sergeev
    the Telerik team
    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 their blog feed now.
  17. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 23 Jul 2013 Link to this post

    So can anyone spell out exactly what needs to be done to disable this app_code/temp folder stuff?  Trying to avoid this if possible and I'm not seeing any direct answer in above posts.
  18. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 26 Jul 2013 Link to this post

    Hi Bob,

    Could you explain what exactly do you want to achieve? You want do change the temporary folder to be different than the App_Data\RadUploadTemp or to disable it at all. Bellow are few approaches you could use:

    To change it:
    1. Set the TemporaryFolder property.

    To disable it (This means to prevent uploading uploading file into the temporary folder):
    1. Set Manualupload to true.
    2. Set DisableChunkUpload to true.
    3. Set TemporaryFolder to point the same location where you will save files.

    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"
        ManualUpload="true"
        TemporaryFolder="~/Uploads"
        OnFileUploaded="RadAsyncUpload1_FileUploaded"
        DisableChunkUpload="true">
    </telerik:RadAsyncUpload>
    <asp:Button runat="server" ID="btnUpload" Text="Upload"/>
    protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
    {
        string path = Server.MapPath("~/Uploads/");
        e.File.SaveAs(path + e.File.FileName);
    }

    Note that when file is selected, RadAsyncUpload is looking for the Temporary folder. It might not save upload file in it, but it will create RadUploadTestFile to verify if the application has write permission.

    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.
  19. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 26 Jul 2013 Link to this post

    I was actually trying to directly save file to database, but I no longer need to use the RadAsyncUpload as I have changed my approach.  My project requirements include a small content management system, so I was able to hook up RadEditor's ImageManager and DocumentManager so they save files directly to database.  So, I'm good now, but thanks for replying with info!
  20. Simone
    Simone avatar
    2 posts
    Member since:
    Sep 2013

    Posted 11 Sep 2013 Link to this post

    Hi,
    i tried to do exactly as Hristo said but i noticed that the indicator of uploading is always red and FileUploaded event is never fired while RadUploadTestFile file in the TemporaryFolder is correctly created.
    this is my code
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" AllowedFileExtensions="csv,txt"
           MaxFileSize="524288" OnFileUploaded="RadAsyncUpload1_FileUploaded" OnClientValidationFailed="validationFailed"
           Skin="Sunset"  DisableChunkUpload="true" TemporaryFolder="~/upload" UseApplicationPoolImpersonation="true" ManualUpload="true">
       </telerik:RadAsyncUpload>

    How can i solve it?

    Regards

    Simone
  21. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 16 Sep 2013 Link to this post

    Hi Simone,

    Usually the red dot appears when the file validation has failed. In your case this will happen if you try to upload file which is not in text or CSV format  or when its size exceed the maximum allowed - 524288 bytes (512KB). Try to handle OnClientValidationFailed event and see why it is fired.

    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.
  22. Simone
    Simone avatar
    2 posts
    Member since:
    Sep 2013

    Posted 16 Sep 2013 Link to this post

    Hi Hristo,
    unfortunately is not my case because, as u can see, i already handled the OnClientValidationFailed event and if i try to upload a different kind of file is working properly. Same thing for the dimension (it's only 1kb the file i try to upload!).
    I found that in one server everything is working with no problems (except i've to use UseApplicationPoolImpersonation="true") while in another server (same code) there's no way to let the dot becoming green.
    Always remains red and no error is fired.

    Just to let u know... if i use a classic html input file there r no problems

    Regards

    Simone
  23. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 19 Sep 2013 Link to this post

    Simone, be sure that application on the second server has write permissions to the Temporary and Target folders. And what about the OnClientFileUploadFailed event, is it fired?

    You may record your web traffic with Fiddler Cap. It will give us more detailed information about the http requests that RadAsyncUpload makes and information about failures.

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017