Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I need to download videos which are located under server to user's specified local path.
I have a web server application and an embedded server application for client side.
Somehow I need to get byte buffer from code behind webmethod then I need to send the byte buffer to my embedded server via ajaxrequest from client side.
How can I do this way, or is there any other way to do it?
Posted
Comments
virusstorm 27-Apr-15 10:00am    
Why not pass the URL of the file into your embedded web server application and simply use the WebClient.DownloadFile to download the file?
kubibay 28-Apr-15 3:55am    
The videos may not be public but when I test the way you suggest I get "The remote server returned an error: (500) Internal Server Error." error..
virusstorm 28-Apr-15 15:05pm    
Are you logging the error details?
kubibay 29-Apr-15 3:22am    
It is happening on downloadfile method.. What details do you mean?
kubibay 29-Apr-15 7:43am    
Ok I found the problem, I can now save the video via webclient.download file. But I would prefer to send video bytes in chunks and for non-public videos.

Use Response.

Set the ContentType to "video/mp4" and use BinaryWrite to send the content.

HTML
Response.ContentType = "video/mp4";
Response.Clear();
Response.BufferOutput = true;
 
// use a reader to load the video content

Response.BinaryWrite(reader.Value);
 
Response.Flush();
 
Share this answer
 
Comments
kubibay 28-Apr-15 3:55am    
The problem is; server can't access the embedded server, so the embedded server side must be done client side, but the mp4 file is located at server side. So I need to get data from code behind and send it from client side? How can we do that?
I can get bytes from webmethod but can't send them to javascript side!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900