jcea
jcea

Reputation: 688

Google drive “patch semantics” and partial file update

Reading https://developers.google.com/drive/api/v3/reference/files/update I see this comment: "This method supports patch semantics.". Googling around, I can't find any description of the meaning of that phrase neither any hint about how to partially update a Google Drive document. The (diverse) source code I have studied just upload the new version of the file, complete.

Thanks!

Upvotes: 1

Views: 710

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116968

It means that it is a HTTP PATCH request as opposed to a HTTP PUT request.

The HTTP PATCH request method applies partial modifications to a resource.

VS

The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.

In the request body, supply the relevant portions of a Files resource, according to the rules of patch semantics.

A PUT would require that you send all of the values and it would update the entire object. Where by a PATCH will only update the parameters you send.

Using the Google drive file update method lets say that you only want to update the file name. Using a PATCH method will allow you to only send the name and only the name would be updated.

However if this was a PUT method every parameter in the object would need to be sent as they will all be updated any parameter that you do not send would then be updated to null.

Upvotes: 1

Related Questions