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

Custom Handler and temp folder.

21 Answers 322 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Adam Nelson
Top achievements
Rank 2
Adam Nelson asked on 28 Aug 2012, 07:58 PM
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

21 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 30 Aug 2012, 07:32 AM
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.
0
Adam Nelson
Top achievements
Rank 2
answered on 30 Aug 2012, 03:23 PM
Thank you for the clarification.
0
Mark
Top achievements
Rank 1
answered on 25 Sep 2012, 10:46 PM
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.
0
Adam Nelson
Top achievements
Rank 2
answered on 25 Sep 2012, 10:55 PM
That's what tripped me up also... the documentation in demos and help seems wrong based on the answer provided here.
0
Mark
Top achievements
Rank 1
answered on 26 Sep 2012, 08:09 PM
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.
0
Plamen
Telerik team
answered on 28 Sep 2012, 03:07 PM
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.
0
Adam Nelson
Top achievements
Rank 2
answered on 28 Sep 2012, 03:09 PM
Sounds great. I'll by trying that out when it's released. Thanks for the heads up.
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 04 Dec 2012, 11:11 PM
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

0
Shawn Krivjansky
Top achievements
Rank 1
answered on 05 Dec 2012, 01:27 AM
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?
0
Peter Filipov
Telerik team
answered on 07 Dec 2012, 12:29 PM
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.
0
Andreas
Top achievements
Rank 1
answered on 01 Feb 2013, 10:39 AM
Hi,

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

Regards
Caesar
0
Genady Sergeev
Telerik team
answered on 01 Feb 2013, 11:43 AM
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.
0
Andreas
Top achievements
Rank 1
answered on 01 Feb 2013, 01:22 PM
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
0
Genady Sergeev
Telerik team
answered on 06 Feb 2013, 01:37 PM
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.
0
Bob
Top achievements
Rank 1
answered on 23 Jul 2013, 09:04 PM
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.
0
Hristo Valyavicharski
Telerik team
answered on 26 Jul 2013, 02:13 PM
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.
0
Bob
Top achievements
Rank 1
answered on 26 Jul 2013, 02:19 PM
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!
0
Simone
Top achievements
Rank 1
answered on 11 Sep 2013, 01:47 PM
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
0
Hristo Valyavicharski
Telerik team
answered on 16 Sep 2013, 11:38 AM
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.
0
Simone
Top achievements
Rank 1
answered on 16 Sep 2013, 12:08 PM
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
0
Hristo Valyavicharski
Telerik team
answered on 19 Sep 2013, 08:44 AM
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.
Tags
AsyncUpload
Asked by
Adam Nelson
Top achievements
Rank 2
Answers by
Bozhidar
Telerik team
Adam Nelson
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Plamen
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
Peter Filipov
Telerik team
Andreas
Top achievements
Rank 1
Genady Sergeev
Telerik team
Bob
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Simone
Top achievements
Rank 1
Share this question
or