我正在使用ObjectiveFlickr库从我的iPhone应用上传照片到Flickr。我可以授权应用程序并执行一般请求,但在尝试上传照片时出现错误。该照片是上传的是使用AVFoundation拍摄的图像。下面是相关的代码:ObjectiveFlickr图片上传错误
UIImage *image = [[UIImage alloc] initWithData:imageData];
if ([[AppDelegate sharedDelegate].apiContext.OAuthToken length]) {
NSData *uploadData = UIImageJPEGRepresentation(image, 1);
if (!flickrRequest) {
flickrRequest = [[OFFlickrAPIRequest alloc] initWithAPIContext:[AppDelegate sharedDelegate].apiContext];
flickrRequest.delegate = self;
flickrRequest.requestTimeoutInterval = 60.0;
}
[flickrRequest uploadImageStream:[NSInputStream inputStreamWithData:uploadData] suggestedFilename:@"Test" MIMEType:@"image/jpeg" arguments:[NSDictionary dictionaryWithObjectsAndKeys:@"0", @"is_public", nil]];
[UIApplication sharedApplication].idleTimerDisabled = YES;
NSLog(@"Can upload photo");
的flickrRequest
对象被定义和@property
倒是在有关上述代码.h文件。
的OFFlickrRequestDelegate
方法如下:
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest imageUploadSentBytes:(NSUInteger)inSentBytes totalBytes:(NSUInteger)inTotalBytes {
NSLog(@"Success");
}
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary {
NSLog(@"%s %@ %@", __PRETTY_FUNCTION__, inRequest.sessionInfo, inResponseDictionary);
}
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didFailWithError:(NSError *)inError {
NSLog(@"%s %@ %@", __PRETTY_FUNCTION__, inRequest.sessionInfo, inError);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[inError description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
当我在设备上运行该项目的控制台显示:
Can upload photo
Success
Success
Success
Success
flickrAPIRequest:didFailWithError:(null) Error Domain=org.lukhnos.ObjectiveFlickr Code=2147418115 "The operation couldn’t be completed. (org.lukhnos.ObjectiveFlickr error 2147418115.)"
通过API的文档,“错误2147418115
”搜索定义为“OFFlickrAPIRequestFaultyXMLResponseError
”。我不确定这意味着什么。也很奇怪 - 当我只是试图上传一张照片时,“成功”出现四次。
利用ObjectiveFlickr“Snap and Run”的示例应用程序可以在我正在测试的同一设备上上传照片。比较我的应用程序和Snap和Run之间的代码,我没有看到可能导致照片无法上传的任何主要差异。
任何帮助将不胜感激。