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
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
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.
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.
Plamen
the Telerik team
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
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?
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
Testing with the 2013 Q1 Beta...
Is this property implemented?
Can't find it...
Regards
Caesar
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
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
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
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
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
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
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
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