iOS中的Google驱动器集成在调用插入时发生错误 [英] Google drive integration in iOS giving error while calling insert

查看:191
本文介绍了iOS中的Google驱动器集成在调用插入时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序中工作,并尝试添加Google API以使用Google驱动器,用户可以在其中存储/共享我的应用程序文件。我找到了 Google云端硬盘教程的优秀教程。我下载了适用于它的示例代码,I下载代码昨天它是
工作良好的文件存储按预期,今天阿金我检查,每次我得到错误meesage。请发现控制台消息


发生错误:错误域= com.google.GTLJSONRPCErrorDomain
代码= 400操作不能(不支持的内容
,类型为application / json-rpc; charset = utf-8)UserInfo = 0x75b11f0
{error =不支持的内容类型为application / json-rpc;
charset = utf-8,GTLStructuredError = GTLErrorObject 0x75a3f90:
{message:Unsupported content with type:application / json-rpc;
charset = utf-8code:400 data:[ 1]},
NSLocalizedFailureReason =(不支持的内容类型:
application / json-rpc; charset = utf-8)}

有人建议我在iOS应用程序中集成G​​oogle驱动器的替代方案。

如果这发生在示例代码中,它本身可能是Google API for iOS可靠地集成到我们的应用程序中。



注意:我创建了kClientSecret和kClientId,并使用Google提供的DrEdit示例代码。


<上传文件时,Google云端硬盘服务中的最近更改要求您指定与application / json-rpc不同的MIME类型。这个MIME类型在使用ObjectiveC SDK时默认使用,因此您需要指定一个。



要使SDK附带的示例工作,请打开DriveWindowController.m并在newFile.title = filename;下的uploadFileAtPath:方法中添加newFile.mimeType = @image / png;。

  GTLDriveFile * newFile = [GTLDriveFile object];将图像/ png更改为您正在上传的文件的MIME类型。 
newFile.title =文件名;
newFile.mimeType = @image / png;

编辑:Google服务器上似乎存在暂时问题


I am working in an application and trying to adding Google API to use Google drive where user can store/share my application files. I found good tutorial for that Google Drive tutorial I downloaded the sample code worked on it, I downloaded the code yesterday it was working good the files are storing as expected, Today agin I am checking, every time I am getting error meesage. please find the console message

An error occurred: Error Domain=com.google.GTLJSONRPCErrorDomain Code=400 "The operation couldn’t be completed. (Unsupported content with type: application/json-rpc; charset=utf-8)" UserInfo=0x75b11f0 {error=Unsupported content with type: application/json-rpc; charset=utf-8, GTLStructuredError=GTLErrorObject 0x75a3f90: {message:"Unsupported content with type: application/json-rpc; charset=utf-8" code:400 data:[1]}, NSLocalizedFailureReason=(Unsupported content with type: application/json-rpc; charset=utf-8)}

can some one suggest me the alternative to integrate the Google drive in iOS app.

if this is happen with the sample code it self how could be the Google API for iOS reliable to integrate in our apps.

Note: I created the kClientSecret and kClientId also to use DrEdit sample code given by the Google.

解决方案

Very recent changes in the Google Drive service obliges you to specify a mime type different than "application/json-rpc" when uploading a file. This mime type is used by default when using the ObjectiveC SDK, so you need to specify one.

To make the sample that ships with the SDK work, open DriveWindowController.m and in the "uploadFileAtPath:" method under "newFile.title = filename;" add "newFile.mimeType = @"image/png";". Change "image/png" to the MIME type of the file you are uploading.

GTLDriveFile *newFile = [GTLDriveFile object];
newFile.title = filename;
newFile.mimeType = @"image/png";

Edited: It also seems that there is temporary problem on Google's servers

这篇关于iOS中的Google驱动器集成在调用插入时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆