こんにちは、Google Drive API サポート スタッフです。
ここ数日、Google ドライブで重大な問題が発生しました。
Docs ドキュメントを画像で更新することはできなくなりました。iPhone アプリが画像付きのドキュメント ドキュメントを更新するリクエストを送信すると、サーバーは OK を返しますが、内部の画像はアップロードされません。
問題を再現するためのコードはこちらです。
- (void)selfOverwriteSelectedFile:(GTLDriveFile *)gtlDriveFile
{
// -- not working type -- can't upload images on ODT, HTML, RTF, PDF
NSString *mimetype = @"application/vnd.oasis.opendocument.text"; //@"text/html" @"application/rtf" @"application/pdf"
//works: DOCX
//NSString *mimetype = @"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
NSString *downloadUrl = [gtlDriveFile.exportLinks additionalPropertyForName:mimetype];
//1st request: download the file
GTMHTTPFetcher *fetcher = [self.driveService.fetcherService fetcherWithURLString:downloadUrl];
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
//2nd request: re-upload the same file
gtlDriveFile.mimeType = mimetype;
GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:mimetype];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesUpdateWithObject:gtlDriveFile fileId:gtlDriveFile.identifier uploadParameters:uploadParameters];
query.convert = query.newRevision = query.setModifiedDate = YES;
[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLDriveFile *newGtlFile, NSError *error2nd) {
}];
}];
}
//replace the method for easy-test
-(void)duplicateSelectedFile
{
GTLDriveFile *selectedFile = [self selectedFileListEntry];
[self selfOverwriteSelectedFile:selectedFile];
}
一番簡単に再現するには、
- 最新の「Objective-C 用 Google API クライアント ライブラリ」をダウンロードします。
- XCode で DriveSample プロジェクトを開きます。
- 「- (void)duplicateSelectedFile」メソッドをコードに置き換えます。
- 修正したサンプルアプリ「Get File List」をコンパイルして実行し、画像付きのdocsファイルを選択して「複製」をタップします。
- 選択したファイルは同じ内容で上書きされます。ただし、内部の画像はすべて失われます (アップロード待ち状態が続くことはありません)。
参考までに、odt/html/rtf/pdf のインポートは機能しません。ただし、docx インポートは機能します。
できるだけ早く問題を解決してください。
ご支援いただきありがとうございます。