|Required for:||Online iOS Android|
The PutFile operation updates a file’s binary contents.
WOPI clients will usually make a Lock request to lock a file prior to calling this operation. The WOPI client will pass the lock ID established by that previous Lock operation in the X-WOPI-Lock request header.
When a host receives a PutFile request on a file that is not locked, the host must check the current size of the file. If it is 0 bytes, the PutFile request should be considered valid and should proceed. If it is any value other than 0 bytes, or is missing altogether, the host should respond with a 409 Conflict. For more information, see Creating new files using Office Online.
If the file is currently locked and the X-WOPI-Lock value does not match the lock currently on the file the host must return a “lock mismatch” response (409 Conflict) and include an X-WOPI-Lock response header containing the value of the current lock on the file. In the case where the file is unlocked, the host must set X-WOPI-Lock to the empty string.
In the case where the file is locked by someone other than a WOPI client, hosts should still always include the current lock ID in the X-WOPI-Lock response header. However, if the current lock ID is not representable as a WOPI lock (for example, it is longer than the maximum lock length), the X-WOPI-Lock response header should be set to the empty string or omitted completely.
- file_id (string) – A string that specifies a file ID of a file managed by host. This string must be URL safe.
- access_token (string) – An access token that the host will use to determine whether the request is authorized.
- X-WOPI-Override – The string
- X-WOPI-Lock – A string provided by the WOPI client in a previous Lock request. Note that this header will not be included during document creation.
- X-WOPI-Editors – A comma-delimited string of UserId values representing all the users who contributed changes to the document in this PutFile request.
The request body must be the full binary contents of the file.
- X-WOPI-Lock – A string value identifying the current lock on the file. This header must always be included when responding to the request with 409 Conflict. It should not be included when responding to the request with 200 OK.
- X-WOPI-LockFailureReason – An optional string value indicating the cause of a lock failure. This header may be included when responding to the request with 409 Conflict. There is no standard for how this string is formatted, and it must only be used for logging purposes.
- X-WOPI-LockedByOtherInterface –
Deprecated since version 2015-12-15: This header is deprecated and should be ignored by WOPI clients.
- X-WOPI-ItemVersion –
For PutFile responses, this should be the version of the file after the PutFile operation.
- 200 OK – Success
- 401 Unauthorized – Invalid access token
- 404 Not Found – Resource not found/user unauthorized
- 409 Conflict – Lock mismatch/locked by another interface; an X-WOPI-Lock response header containing the value of the current lock on the file must always be included when using this response code
- 413 Request Entity Too Large – File is too large; the maximum file size is host-specific
- 500 Internal Server Error – Server error
- 501 Not Implemented – Operation not supported