Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Vladimir K.2
10 years agoNew member | Level 1
HTTP API V2 download range request: strange behaviour
Hi! I'll appreciate any help. Thank you!
I'm trying to download file by chunks.
URL: https://content.dropboxapi.com/2/files/download
File size: 1200 bytes
First time (after creation in dropbo...
Vladimir K.2
10 years agoNew member | Level 1
I don't know how to get raw requests, because they are generated by the following obj-c code.
+ (CloudHTTPResponse*) sendDownloadRequestWithToken:(NSString*)token path:(NSString*)path offset:(UInt64)offset andLength:(UInt64)length {
NSString *url = @"https://content.dropboxapi.com/2/files/download";
NSString *json = [NSString stringWithFormat:@"{\"path\": \"%@\"}", path];
NSURL *urlWithArgs = [NSURL URLWithString:
[NSString stringWithFormat:@"%@?arg=%@", url, [json stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlWithArgs];
[request setHTTPMethod:@"GET"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"];
[request setValue:[NSString stringWithFormat:@"bytes=%llu-%llu", offset, offset+length-1] forHTTPHeaderField:@"Range"];
return [self sendRequestSynchronously:request];
}
+ (CloudHTTPResponse*) sendRequestSynchronously:(NSURLRequest*)request {
NSLog(@"%@", [request URL]);
NSLog(@"%@", [request HTTPMethod]);
NSLog(@"%@", [request allHTTPHeaderFields]);
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
NSURLSession *session = [NSURLSession sharedSession];
__block CloudHTTPResponse *httpResponse = nil;
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
httpResponse = [[CloudHTTPResponse alloc] initWithHeaderFields:[(NSHTTPURLResponse *)response allHeaderFields]
statusCode:(int)[(NSHTTPURLResponse *)response statusCode]
data:data
andError:error];
dispatch_semaphore_signal(semaphore);
}];
[task resume];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
NSLog(@"%i", httpResponse.statusCode);
NSLog(@"%@", httpResponse.headerFields);
return httpResponse;
}
As you can see, headers are printed right before sending the request and after receiving the response.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!