Download a document
- Sandbox: available
- Staging: available
- Production: unknown
Downloads the file of a document by answering with a redirect to a short-lived signed URL. Use it to show or download a file you have access to.
Auth: bearer token. The DocumentReference is read with your token, so you need read access to it.
Behaviour
- The response is
307 Temporary Redirect. TheLocationheader holds the file URL. Follow the redirect to get the file. - For files Ovok stored, the signed URL is valid for one hour. Images (
image/jpeg,image/jpg,image/png,image/gif,image/webp) are served inline; every other type is served as an attachment with the document's file name. - Pass
widthandheighttogether to get a resized copy of an image. Both must be positive integers up to 16384.fitsets how the image fits the box (coverby default; alsocontain,fill,inside,outside). The resized copy is cached, so later requests for the same size are fast. Files that are not resizable images, and images larger than 40 MB, are returned unchanged. - If the image cannot be resized, the original file is returned.
Example
curl -L 'https://api.sandbox.ovok.com/document/c3499c27-2973-0a7f-807e-fb8676a92dcb?width=200&height=200&fit=cover' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -o cat.pngbearerAuthorizationBearer <JWT>id*stringThe id of the DocumentReference resource
uuidwidth?stringThe width of the binary resource if the resource is an image.
height?stringThe height of the binary resource if the resource is an image.
fit?stringThe fit of the image. See https://sharp.pixelplumbing.com/api-resize#fit for more information.
"cover""cover""contain""fill""inside""outside"ETag?stringThe ETag of the file for GET requests. If provided, the server will check the value of the ETag against the value of the ETag in the request headers. If the values match, the server will return a 304 Not Modified response. If the values do not match, the server will return a 200 OK response and the file content, if the file exists.
Redirect to a signed download URL.
curl -X GET 'https://api.sandbox.ovok.com/document/497f6eca-6276-4993-bfeb-53cbbbba6f08'Download a public document GET
Downloads the file of a public document, without a bearer token. Use it to embed a file in a web page or an email, for example in an `<img>` tag. **Auth:** none. The public token in the path is the credential: anyone with the URL can get the file. ## Behaviour - The token is the document's `publicToken`. A document gets one when it is created or updated with `isPublic` set to true. - The response is `307 Temporary Redirect` to a signed file URL, as in `GET /document/{id}`, including the same resizing options (`width`, `height`, `fit`). - A token stops working when the document is made private again, or when its public token is replaced. ## Example ```bash curl -L 'https://api.sandbox.ovok.com/document/public/example.jwt.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' -o file.png ```
Create document replacement credentials POST
Replaces the file of an existing document. It updates the document's metadata and returns a signed upload form, as `POST /document` does. **Auth:** bearer token. The document is read and updated with your token, so you need update access to the DocumentReference. ## Behaviour - `fileName` and `contentType` are required and set on the document. `isPublic` is optional and works as in `PATCH /document/{id}`. - The current file is deleted before the upload form is returned. Until you upload the new file, the document has no file to download. - The document keeps its id, so existing references to it stay valid. - Upload with `uploadOptions` as described for `POST /document`. The form expires after 10 minutes. ## Example ```bash curl -X POST 'https://api.sandbox.ovok.com/document/c3499c27-2973-0a7f-807e-fb8676a92dcb' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -H 'Content-Type: application/json' \ -d '{ "fileName": "new-cat.png", "contentType": "image/png" }' ```