Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set the modifiedDate on a google drive file in iOS AND prevent duplicate file names
    primarykey
    data
    text
    <p>I found the way in iOS (not obvious to me) to insert a file into a google drive folder using the standard queryForFilesInsertWithObject with uploadParameters and setting the folder id in a GTLDriveParentReference object, adding that object to an array, and assigning that array to the uploaded file's "parents" property. What I haven't yet figured out is how to overwrite any existing google drive file with a newer version without creating a duplicate. I would also like to stamp the new uploaded google drive file with the same date-time stamp as my local device file. When I try to use the file/update method and set the file.modifiedDate and query.setModifiedDate=YES, I always get a 400 Bad Request.</p> <p>I can use patch to change the title just fine, but I can't set the modifiedDate using the api. I was able to change the modifiedDate using Google's Try it! APIs Explorer, so Google's servers are working fine. Here is the code that fails:</p> <pre><code>GTLDriveFile *file = [GTLDriveFile object]; NSString *fId = insertedFile.identifier; file.title = @"Tony.jpg"; file.modifiedDate = myNewGoogleDate; // "2012-12-31T08:00:00+00:00" GTLQueryDrive *qu = [GTLQueryDrive queryForFilesPatchWithObject:file fileId:fId]; qu.setModifiedDate = YES; [service executeQuery:qu completionHandler:^(GTLServiceTicket *ticket,... </code></pre> <p>Take out the two lines with modifiedDate and the google-drive file title changes just fine. I traced into the api call to executeQuery and found that the following results as "DataToPost".</p> <pre><code>{"method":"drive.files.patch","id":"gtl_7","jsonrpc":"2.0", "params": {"setModifiedDate":true,"resource": {"modifiedDate":"2012-12-31T08:00:00+00:00", "title":"Tony.jpg"},"fileId":"0BxRlXPR_hfR9OEJSdDdyQjkyaE0"},"apiVersion":"v2"} </code></pre> <p>Does anyone see "Bad Request" in this post? The error returned from the executeQuery is:</p> <pre><code>Error Domain=com.google.GTLJSONRPCErrorDomain Code=400 "The operation couldn’t be completed. (Bad Request)" UserInfo=0x80724b0 {error=Bad Request, GTLStructuredError=GTLErrorObject 0x806a7a0: {message:"Bad Request" code:400 data:[1]}, NSLocalizedFailureReason=(Bad Request)} </code></pre> <p>Does anyone have some code to set the modifiedDate that works?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload