NSURLErrorDomain error -1021

前端 未结 2 1979
感情败类
感情败类 2021-01-07 07:53

I\'m developing an app were I integrated dropbox. Login is done properly also I\'m able to create folder in dropBox. But when I try to load file I\'m getting error

F

相关标签:
2条回答
  • 2021-01-07 08:35

    I had the same problem with iOS 5.0 on iPhone, but the iPhone 6.1 simulator worked without creating error messages.

    I took a look into the DropboxSDK / DBRestClient.m, especially the last lines of uploadFile:toPath:fromPath:params and implemented a categorie 'ExBody' on DBRequest to add the connection:needNewBodyStream method:

    #import "DBRequest+ExBody.h"
    
    @implementation DBRequest (ExBody)
    
    #pragma mark NSURLConnection delegate methods
    
    - (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)req {
    
        NSString * sourcePath = [userInfo objectForKey:@"sourcePath"];
        NSLog(@"%@ needs newBodyStream!", sourcePath);
        return [NSInputStream inputStreamWithFileAtPath:sourcePath];
    }
    
    @end
    

    This worked for me. The method is called on iOS5, not on iOS6!

    0 讨论(0)
  • 2021-01-07 08:47

    Error -1021 is a NSURLErrorRequestBodyStreamExhausted error.

    According to the documentation you're missing a delegate method:

    NSURLErrorRequestBodyStreamExhausted
    Returned when a body stream is needed but the client does not provide one. This impacts clients on iOS that send a POST request using a body stream but do not implement the NSURLConnection delegate method connection:needNewBodyStream. Available in OS X v10.7 and later.

    0 讨论(0)
提交回复
热议问题