1

I have 60 MB of file and I want to download this file in part by part from 2 or more separate threads. Would it be possible to download file from byte range option from each thread separately.

Here are the data which I am getting from server in response.

"Accept-Ranges" = bytes;
Age = 46330;
Connection = "keep-alive";
"Content-Length" = 1001;
"Content-Range" = "bytes 0-1000/6116016";
"Last-Modified" = "Wed, 30 Nov 2016 10:55:52 GMT";
"X-Cache" = "Hit from cloudfront";

Like for thread one :

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

NSString* range = @"bytes=";
range = [range stringByAppendingString:[[NSNumber numberWithInt:0] stringValue]];
range = [range stringByAppendingString:@"-"];
range = [range stringByAppendingString:[[NSNumber numberWithInt:1000] stringValue]];

[request setValue:range forHTTPHeaderField:@"Range"];

For thread 2 :

 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    NSString* range = @"bytes=";
    range = [range stringByAppendingString:[[NSNumber numberWithInt:1000] stringValue]];
    range = [range stringByAppendingString:@"-"];
    range = [range stringByAppendingString:[[NSNumber numberWithInt:2000] stringValue]];

    [request setValue:range forHTTPHeaderField:@"Range"];
Ashwini Chougale
  • 1,093
  • 10
  • 26
Ajay_Kumar
  • 1,381
  • 10
  • 34
  • 62

0 Answers0