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 파일 거라고 다음은 관련 코드이다. 내가 장치에 프로젝트를 실행하면
- (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];
}
콘솔을 보여줍니다 다음과 같이
OFFlickrRequestDelegate
방법
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 and Run 사이의 코드를 비교하면 사진을 업로드하지 못하게하는 주요 차이점이 보이지 않습니다.
도움을 주시면 감사하겠습니다.