UpdateResource Method
Updates a file or folder.
Syntax
googledrive.updateResource(resourceId, [callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
This method updates the metadata for the file or folder resource identified by ResourceId. For file resources, the file data can optionally be updated as well.
Usage
There must be an item in the Resource* properties whose ResourceId property matches the specified ResourceId value before this method is called.- If necessary, call GetResourceInfo or ListResources to ensure an item with the resource's latest information is present in the Resource* properties.
- Modify the item's Resource* properties as desired; the following properties are supported:
- ResourceContentAccessible
- ResourceDescription
- ResourceMIMEType (only updated for files, if not empty and new file data is uploaded)
- ResourceModifiedTime (only updated if not empty)
- ResourceName
- ResourceStarred
- ResourceTrashed
- For file resources, you may set LocalFile or ResourceData if you wish to update the file data on the server. (Refer to UploadFile for more information about simple vs. resumable uploads and encrypting the file data before uploading.)
- Finally, call this method to update the resource.
// Load the latest information about the resource into the Resources collection. string resId = "2309urjdojwefs0d09u"; googledrive.GetResourceInfo(resId); // We'll update the file resource's name, description, and content. googledrive.ResourceData = "new file content"; googledrive.Resources[0].Name = "CoolStuff2.txt"; googledrive.Resources[0].Description = "This is a text file with cool stuff in it"; googledrive.UpdateResource(resId);