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

Upload save as conversion

6 Answers 114 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 08 Mar 2010, 09:21 PM
I'm using the RadUpload to allow users to upload an image file.  I need access to the file stream so that I can convert and resize the image.  I need to do this on the handler side because Silverlight does not have access to System.Drawing.  I do not have a good enough understanding of the whole chunk upload setup to know where I can grab the file data in order to do this.  I do not want to have to save the file first and then convert it.

Any suggestions?

Thanks!

6 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 09 Mar 2010, 10:05 AM
Hi Angie,

RadUpload sends the files in chunks to the server handler. You can alter this behavior if you set a bigger BufferSize so that the file can be uploaded at once, but this will lead to another problems - big memory consumption on the client and you will need to alter the server configuration to allow larger post requests.

So the recomended way will be to alter the upload handler and to add your logic for the image processing when the last chunk of the file is sent. After you modify the image you can remove the temporary data which was received so far.

For more info please read the following help article:
http://www.telerik.com/help/silverlight/creating_custom_server-side_handler.html

Please let us know if you have any questions.

BTW: there is also a nice discussion about resizing image on the SL client. It may help you decide making the image processing on the client:
http://forums.silverlight.net/forums/t/117220.aspx

All the best,
Valentin.Stoychev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Angie
Top achievements
Rank 1
answered on 18 May 2010, 05:11 PM
In the custom handler, what object do I need to refer to in order to access the file stream?   I'm not sure what you mean by removing the temporary data.  Also, is there a variable that contains my filenames or do I have to pass parameters?

Is there a way to get an example for this? 

Thank you.
0
Miro Miroslavov
Telerik team
answered on 21 May 2010, 07:31 AM
Hello Angie,

When you upload an image (file) to the server - the server gets the bytes stream of that image, so you can manipulate the stream like, create Image from that stream, manipulate it, and save it on the file-stream. (and all this is done on server-side.) You may read more about the RadUploadHandler here, and get the ide of how to get the Image stream.

But you'd better re-size the image on the client and send it after that. That way you'll generate much smaller traffic and save server's overhead. You can read more on this here.

Kind regards,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Angie
Top achievements
Rank 1
answered on 01 Jun 2010, 05:52 PM
It would be really helpful if you could provide a context for how to do this.

Do I do the clientside conversion on the UploadStarted or the FileUploadFinished event or somewhere else?  (I will be handling multiple files.)

Once I have the encoded filestream, do I pass that stream to the RadUploadHandler.ashx or do I need to create my own ServiceClient as in the silverlight example?

The rest of the scenario:

I need to be able to save both a regular image and also a thumbnail image.
I need to save the file information to the database.

Thank you!!
0
Angie
Top achievements
Rank 1
answered on 03 Jun 2010, 03:50 PM
Can someone please help me with this?  I am losing precious development time while I wait for a response.

Edit:  If you point me toward the Custom RadUploadHandler, please be as detailed as possible.  Thank you.
0
Miro Miroslavov
Telerik team
answered on 04 Jun 2010, 11:59 AM
Hello Angie,

Yes, you'll need a Custom upload handler. In that handler you'll have to:
  1. Process the stream of coming articles. This article will guide you. Processing means:
    1. Create image from the file/stream.
    2. Do what you need with that image - Resize it, persist the thumbnail in the DB and persist the original stream(image) as well.

On the client site you don't need to do anything in the case you need both the thumbnail and the original image.
Hope this was helpful.
Sincerely yours,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Upload
Asked by
Angie
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Angie
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Share this question
or