downloading a large file!

  • Thread starter Thread starter DBC User
  • Start date Start date
D

DBC User

Hi All,

Quick question, in my program I need to download a large file (100MB)
file. I would like to know how can I do this in segments so that if the
download fails, I will able to download from the the place where the
download fails.

Thanks.
 
Hi,

DBC User said:
Hi All,

Quick question, in my program I need to download a large file (100MB)
file. I would like to know how can I do this in segments so that if the
download fails, I will able to download from the the place where the
download fails.

For this to work you need to control both ends of the transmition, do you?
if so you would have to send in the request the offset from the beginning of
the file, after that is as usual, get the bytes, and append them to the
file.
 
I believe you can use HTTP for this. The 1.1 specification has a
provision in it (in the form of a header I believe) which you can set to
indicate where to start the download from. This way, you can indicate which
byte to start at, and then just append to your file.

Hope this helps.
 
Hello Nicholas Paldino [.NET/C# MVP],
I believe you can use HTTP for this. The 1.1 specification has a
provision in it (in the form of a header I believe) which you can set
to indicate where to start the download from. This way, you can
indicate which byte to start at, and then just append to your file.

Hope this helps.

This header is called "Range". Using it, one can specify one or multiple
byte segments to be retrieved.

Cheers,
 
It should be noted that you cannot assume that all servers will allow
this. So in that case you'll need to restart the entire download if the
server you are connecting to doesn't support Range.

--
Benny Raymond
http://bloatedcowsoftware.com

Joerg said:
Hello Nicholas Paldino [.NET/C# MVP],
I believe you can use HTTP for this. The 1.1 specification has a
provision in it (in the form of a header I believe) which you can set
to indicate where to start the download from. This way, you can
indicate which byte to start at, and then just append to your file.

Hope this helps.


This header is called "Range". Using it, one can specify one or multiple
byte segments to be retrieved.

Cheers,
 
Hello Benny,
It should be noted that you cannot assume that all servers will allow
this. So in that case you'll need to restart the entire download if
the server you are connecting to doesn't support Range.

That's correct. A server that supports Range requests should advertise this
capability using the "Accept-Ranges" header.

Cheers,
 
let me see if I understood this correct

I guess I need to have control over both side and I do. (I am writing a
tray item do this task). From the client side, I call a http page to do
the download (Are we taking file copy over http??) as the file copy is
running I keep track of the offset. If the download breaks in the
middle (that is no response from the server or any other failure), I
re-request the file copy, during the request, I will pass the offset in
the http (how can I do that). To make this happen, I have to have the
download server configured to handle accept-ranges (Where do I do
that??).

Thanks.
 
Hello DBC,
let me see if I understood this correct

I guess I need to have control over both side and I do. (I am writing
a tray item do this task).

Not really. You just need to identify those servers that accept Range requests.
If a server doesn't support Ranges, you have to repeat the entire download
from scratch.
From the client side, I call a http page to
do the download (Are we taking file copy over http??) as the file copy
is running I keep track of the offset.

Yes, HTTP. I assumed that sort of blindly after Nicolas' reply.
If the download breaks in the
middle (that is no response from the server or any other failure), I
re-request the file copy, during the request, I will pass the offset
in the http (how can I do that).

Add a Range header to your HttpWebRequest by calling AddRange().
To make this happen, I have to have
the download server configured to handle accept-ranges (Where do I do
that??).

That depends on the server or the web application (if there's one involved).
What are using? IIS? Apache?

Cheers,
 
I am developing this application using .Net C# 2005 and my IIS is
Windows. As I mentioned, I have a tray icon process which runs in the
background and when it sees a request to download, it will start
downloading based on what I find here. I have 6 servers which are
dedicated to do downloading. All are load balanced.
 
Hi Jorge,
"Not really. You just need to identify those servers that accept Range
requests.
If a server doesn't support Ranges, you have to repeat the entire
download
from scratch. "

In here how can you make the server to support ranges?

Thanks a lot for all the explanation.
 
Back
Top