且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用iPhone版Google云端硬盘SDK在Google云端硬盘上创建文件夹?

更新时间:2023-02-14 14:15:22

我看不到您创建文件夹的代码,但是我自己在创建文件夹时遇到了同样的问题.如您所知,mimeType必须为"application/vnd.google-apps.folder".如果uploadDatasWithData的NSData参数为nil,我会遇到断言失败.所以我尝试了一个零长度的NSData对象,但是失败了.使用1字节的NSData对象也失败.诀窍是使用uploadParameters:nil调用queryForFilesUpdateWithObject.然后,文件夹创建工作正常.我还发现在末尾显示了Objective-C代码:

I don't see your code to create a folder, but I was having the same problem with folder creation myself. As you know, the mimeType must be "application/vnd.google-apps.folder". I ran into assert failures if the NSData parameter to uploadParametersWithData was nil. So I tried a zero length NSData object and that failed. Using a 1 byte NSData object also failed. The trick is to call queryForFilesUpdateWithObject with uploadParameters:nil. Then the folder creation works fine. I also discovered that the Objective-C code shown at the end of:

https://developers.google.com/drive/v2/reference/文件/插入

不正确. file.parents应该如下:

is incorrect. The file.parents should be as follows:

GTLDriveParentReference *parentRef = [GTLDriveParentReference object];
parentRef.identifier = parentID;
if (parentID.length>0) file.parents = [NSArray arrayWithObjects:parentRef,nil];