Upload Handler
The RadUpload control must use an upload handler on the server in order to transfer its data.
This handler is represented by a Generic (ASHX) Handler class that derives from the RadUploadHandler class. This topic will make you familiar with the RadUploadHandler class and its most important members as follows.
Uploading concepts
When a file is being uploaded, it gets separated in chunks. Each chunk gets transferred via the upload handler. The size of the chunks depends on the size of the buffer of the RadUpload control. See how to set this up in the Buffering article.
Each time a chunk gets transferred, a set of methods get executed on the server. If the chunk is the last from a file, the client is notified when the chunk is saved and the FileUploaded event gets raised by the RadUpload control. When the chunk is the last for the upload, the UploadFinished event gets raised, too.
The RadUploadHandler class provides you with virtual methods, which can get overridden in order to customize the behavior of the handler. Read the rest of the topic to learn more about the methods and the properties of the class.
Methods
AddReturnParam - appends a return parameter with its value.
CancelRequest - invoked on upload-cancelation. Removes the canceled file. The method can be overridden.
GetAssociatedData - prepares a dictionary for associated (custom) data returned to the client on each Final-file-request. The method can be overridden.
GetFileName - returns the name of the uploaded file. The method can be overridden.
GetFilePath - constructs the full name of the uploaded file. The method can be overridden.
GetQueryParameter - returns a Value linked to the specified key in the current Request Query. The method can be overridden.
GetTargetFolder - constructs the full path for the target folder. The method can be overridden.
Initialize - a place for first-time initialization of a custom-handler. The method can be overridden.
InitializeChunkStorage- a place for first-time initialization of a custom-handler. The method can be overridden.
InvalidRequest - prepares return parameters when the upload-request is invalid. The method can be overridden.
IsFinalFileRequest - returns true if the current request contains the final chunk of the uploaded file. The method can be overridden.
IsFinalUploadRequest - returns true if the current request contains the final chunk of the last of the uploaded files. The method can be overridden.
IsNewFileRequest - returns true if the current request contains the first chunk of the uploaded file. The method can be overridden.
IsValidRequest - checks the validity of the current upload request. The method can be overridden.
OpenTargetFile - Opens the target file.
ProcessRequest - processes the HTTP Web request. The method can be overridden.
ProcessStream - the backbone of request-processing mechanism. The method can be overridden.
RemoveFile - removes the specified file. The method can be overridden.
SaveChunkData - saves the chunk's data in a file with the given name. The method can be overridden.
Override this method in order to implement a custom logic inside the handler.
- SendResponse - writes all the return parameters to the Response stream.
Properties
Context - HttpContext object that provides references to the intrinsic server objects (Request, Response, etc.) used to service HTTP requests.
FormChunkTag - gets the Chunk-tag value sent by the client.
IsReusable - gets a value indicating whether another request can use the IHttpHandler instance. The property can be overridden.
OverwriteExistingFiles - gets or sets the value indicating whether RadUpload should overwrite existing files having the same name in the TargetFolder. The property can be overridden.
Request - a HttpRequest object for the current HTTP request.
Result - a container for all parameters returned to the client. The property can be overridden.
ResultChunkTag - gets or sets the Chunk-tag value returned to the client.
TargetFolder - gets or sets the virtual path of the folder, where RadUpload will automatically save the valid files after the upload completes. The property can be overridden.
-
TargetPhysicalFolder - gets or sets the physical path of the folder, where RadUpload will automatically save the valid files after the upload completes. The property can be overridden.
After version LIB
2020.1.413
(inclusive) of Telerik UI for Silverlight, the TargetPhysicalFolder property is not used by the default implementation of RadUploadHandler due to security reasons. To get the same effect (avoid providing physical folder to the upload handler) in previous versions you can implement a custom upload handler. One way to do this is described in the Secure Upload File Paths article. To enable the TargetPhysicalFolder property in version2020.1.413
and later see the Use TargetPhysicalFolder article.