我在ios 10.1上使用Google Drive Rest API,并且能够列出文件元数据并获取文件内容。
当我尝试在appDataFolder中创建文件时,我收到内部错误500。我很感激您对此的见解。
这是我的代码:
NSURL *url = [[ NSURL alloc ] initFileURLWithPath:filePath isDirectory:NO ];
GTLRUploadParameters *uploadParameters = [ GTLRUploadParameters uploadParametersWithFileURL:url
MIMEType:mimeType];
GTLRDriveQuery *query ;
if (metadata == NULL)
{
metadata = [ GTLRDrive_File object ];
metadata.name = fileName;
if (folderId != NULL)
{
metadata.parents = @[ folderId ];
}
// This is a new file, instantiate an insert query.
query = [ GTLRDriveQuery_FilesCreate queryWithObject:metadata
uploadParameters:uploadParameters ];
}
else
{
// This file already exists, instantiate an update query.
query = [ GTLRDriveQuery_FilesUpdate queryWithObject:metadata
fileId:metadata.identifier
uploadParameters:uploadParameters ];
}
query.fields = queryFileFieldsParam;
[ weakSelf.googleDriveService executeQuery:query completionHandler:^(GTLRServiceTicket *ticket,
GTLRDrive_File *updatedMetadata,
NSError *error)
{
if (error == nil)
{
completionBlock(updatedMetadata);
}
else
{
NSLog(@"An error occurred: %@", error);
}
}];