Hi,
Do you have a sample working custom server-side handler that demostrates more about the ProcessStream()?
Thanks.
Do you have a sample working custom server-side handler that demostrates more about the ProcessStream()?
public override void ProcessStream() |
{ |
base.ProcessStream(); |
if (this.IsFinalFileRequest()) |
{ |
// Insert here your custom logic for processing the file stream. |
// You can read the saved file on the disc and to process it in the way you need. |
// You can save the file in DB, compress it, etc. |
// you can access the form parameters by using the RadUploadConstants |
string targetFolder = this.Request.Form[RadUploadConstants.ParamNameTargetFolder]; |
// Or by using the predefined properties/methods in the base handler |
string targetFolder2 = this.TargetFolder; |
string targetPhysicalFolder = this.TargetPhysicalFolder; |
bool isFinalRequest = this.IsFinalFileRequest(); |
// to send back a parameter - for example the error message, or the result from the upload operation |
// use the AddReturn |
this.AddReturnParam(RadUploadConstants.ParamNameSuccess, false); |
this.AddReturnParam(RadUploadConstants.ParamNameMessage, "Unable to open the Database"); |
} |
} |
Thanks.
9 Answers, 1 is accepted
0
Hi Tony,
We don't have an example application with a custom server side handler. What is the scenario that you are into?
Regards,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
We don't have an example application with a custom server side handler. What is the scenario that you are into?
Regards,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tony
Top achievements
Rank 1
answered on 05 Jan 2009, 04:50 PM
Hi Valentin:
Here are the requirements for my upload process:
After one file upload starting or uploaded, I need to:
- Rename the file and save it to a specific folder
- Generate a thumbnail from the file and save it to the database
- Retreive the file information and save it to the database
Do I do these tasks inside the ProcessStream()?
Thanks
Tony
Here are the requirements for my upload process:
After one file upload starting or uploaded, I need to:
- Rename the file and save it to a specific folder
- Generate a thumbnail from the file and save it to the database
- Retreive the file information and save it to the database
Do I do these tasks inside the ProcessStream()?
Thanks
Tony
0
Hi Tony,
Yes, this is the place to perform these tasks. If you place your logic inside the IF statement it should be ok.
Please let us know how it goes.
Greetings,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Yes, this is the place to perform these tasks. If you place your logic inside the IF statement it should be ok.
public override void ProcessStream() |
{ |
base.ProcessStream(); |
if (this.IsFinalFileRequest()) |
{ |
// place your code here |
} |
} |
Please let us know how it goes.
Greetings,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tony
Top achievements
Rank 1
answered on 06 Jan 2009, 07:58 AM
Hi Valentin:
Thanks for the info, that should work for now.
Also, can we access HttpContext from the handler? Or anyway we pass some data to it? I need to pass a different target folder path for different uploads.
Thanks
Tony
Thanks for the info, that should work for now.
Also, can we access HttpContext from the handler? Or anyway we pass some data to it? I need to pass a different target folder path for different uploads.
Thanks
Tony
0
Hi Tony,
Check this help article:
http://www.telerik.com/help/silverlight/passing_custom_params_to_the_server_side_handler.html
Best wishes,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Check this help article:
http://www.telerik.com/help/silverlight/passing_custom_params_to_the_server_side_handler.html
Best wishes,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Geovani
Top achievements
Rank 1
answered on 05 Jan 2011, 03:56 AM
Hello,
I’ve tried to use your code, but it isn’t working when I upload more than 1 file because this method is returning true just when the last file is updated.
So I’ve implemented this code and now it is working ok, because I’m calling the method IsFinalFileRequest before call the ProcessStream method. What could I do to throw an exception and show it in the upload component?
bool finalFileRequest = this.IsFinalFileRequest();
base.ProcessStream();
if (finalFileRequest)
{
try
{
// My code.
}
catch
{
// How could I throw the exception here and show it in the component.
}
}
Thanks
0
Hi Geovani,
A few months ago the RadUpload control was modified to introduce new functionality. However, a few changes were introduced. Please have a look at this article to learn more info.
Also, you may find useful the following articles as well:
I hope this information will help you implement your scenario. Still, if you need more info please let us know.
All the best,
Tina Stancheva
the Telerik team
A few months ago the RadUpload control was modified to introduce new functionality. However, a few changes were introduced. Please have a look at this article to learn more info.
Also, you may find useful the following articles as well:
- RadUpload for Silverlight in the Image Gallery example
- Saving files with unique name on the server using RadUploadHandler
- Simple authentication with RadUpload
- Customize the Upload Storage
I hope this information will help you implement your scenario. Still, if you need more info please let us know.
All the best,
Tina Stancheva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
MD
Top achievements
Rank 1
answered on 19 Oct 2011, 07:15 PM
Why is it that IsFinalFileRequest() returns true in ProcessStream only when it is the last chunk of the last file when there are multiple files uploaded and IsFinalFileRequest() is called after the base call? It returns true before you call the base.ProcessStream() when it is the last chunk of a file regards of the file's position when there are multiple ones, but it returns false when called after base.ProcessStream() when the file is not the last one even though it is the last chunk of that file.
0
Hello MD,
The main logic processing the stream of the selected files is in the ProcessStream() method. It is called as soon as the handler receives a file for upload and then it interacts and triggers most of the methods of the RadUploadHandler. This is why if you want to customize the behavior of the UploadHandler, it is safer to override the SaveChunkData() method which is called as soon as a chunk of file is processed. If you want to implement custom logic as soon as the last chunk of a file is processed - it is best to place this logic in the SaveChunkData() method.
Kind regards,
Tina Stancheva
the Telerik team
The main logic processing the stream of the selected files is in the ProcessStream() method. It is called as soon as the handler receives a file for upload and then it interacts and triggers most of the methods of the RadUploadHandler. This is why if you want to customize the behavior of the UploadHandler, it is safer to override the SaveChunkData() method which is called as soon as a chunk of file is processed. If you want to implement custom logic as soon as the last chunk of a file is processed - it is best to place this logic in the SaveChunkData() method.
Kind regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>