6
嗨谷歌雲端硬盤API支持人員,谷歌驅動器(文件)導入錯誤:在更新文件未顯示圖像文件
在過去的幾天裏,我們曾與谷歌雲端硬盤嚴重的麻煩。
我們無法再用圖像更新文檔文檔。當我們的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];
}
對於最簡單的再現,
- 下載最新的 「谷歌API客戶端庫的Objective-C」。
- 在XCode中打開DriveSample項目。
- 用代碼替換「 - (void)duplicateSelectedFile」方法。
- 編譯並執行修改後的示例應用程序「獲取文件列表」,選擇包含圖像的文檔文件,然後點擊「重複」。
- 所選文件應該被覆蓋相同的內容。但是,內部的圖像全部丟失(在無處不在的等待上傳狀態)。
僅供參考,odt/html/rtf/pdf導入不起作用。但是,docx導入工作。
請儘快解決問題。
感謝您的支持。