1

現在、以下のようなObjectiveCクライアントを使用してPicasaに写真をアップロードしようとしています。

GDataServiceGooglePhotos* service =
[self photoService];

// get the URL for the album
NSURL *albumURL = [GDataServiceGooglePhotos
                photoFeedURLForUserID:userEmailAdress albumID:albumName
                   albumName:nil photoID:nil kind:@"album" access:@"all"];

// set a title and description for the new photo
NSDateFormatter *df = [[NSDateFormatter alloc] init];
df.dateFormat  = @"yyyyMMddHHmmssSSSS";
GDataTextConstruct *title, *desc;
title = [GDataTextConstruct textConstructWithString:[df stringFromDate:[NSDate date]]];
desc = [GDataTextConstruct textConstructWithString:[descriptionTextfield text]];

GDataEntryPhoto *newPhoto = [GDataEntryPhoto photoEntry];
[newPhoto setTitle:title];
[newPhoto setPhotoDescription:desc];

// attach the photo data
NSData *data = UIImageJPEGRepresentation(imageView.image, 1.0);
[newPhoto setPhotoData:data];
[newPhoto setPhotoMIMEType:@"image/jpeg"];
[newPhoto setUploadData:data];
[newPhoto setUploadMIMEType:@"image/jpeg"];
[newPhoto setUploadSlug:title.stringValue];


// now upload it
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:newPhoto forFeedURL:albumURL delegate:self didFinishSelector:@selector(addPhotoTicket:finishedWithEntry:error:)];
[service setServiceUploadProgressSelector:nil];

そしてこれが私のaddPhotoTicket:finishedWithEntry:error:メソッドです

 if (error == nil) {
    NSLog(@"UPLOADED");
} else {
    NSLog(@"THERE WAS AN ERROR");
}

「エラーが発生しました」というメッセージが表示され続け、failedWithStatus:400データ:写真データまたはソースIDを含める必要があります。どんな助けでも大歓迎です。

ありがとう。

4

1 に答える 1

1

GooglePhotosSampleアプリケーションに示されているように、アップロードはアルバムのURLに行う必要がありますuploadLink。アップロードのためにアルバムのURLを手動で作成しようとしないでください。アルバムIDはアルバムの名前ではありません。

UIImageJPEGRepresentation簡単に失敗する可能性があります。nil以外のデータを返していることを確認してください。

setPhotoData:およびはとのsetPhotoMIMEType:同義語です; 両方を呼び出す必要はありません。setUploadData:setUploadMIMEType:

setTitle:また、setPhotoDescription:「WithString」バージョンがあるため、それらを設定するためにテキスト構造を明示的に作成する必要はありません。

ライブラリのhttpロギングを有効にして、実際のサーバーの要求と応答を確認します。

于 2012-09-09T16:34:33.630 に答える