File Uploads

Create an uploaded file

Create an uploaded file after uploading the raw file to our file server.

The entire flow for uploaded files to us is as follows:

  1. Call the generate-upload-url endpoint to initiate an upload.
  2. POST your file to the returned URL, including the returned form data.
  3. Call this endpoint to register your uploaded file with our system.

It would look something like this in python:

import requests
api_session = requests.Session()
api_session.headers.update({"Authorization": f"Bearer {API_KEY}"})
s3_session = requests.Session()

# Step 1: Get an upload URL.
response = api_session.post(
    f"{VETCOVE_API_SERVER}/ext/v2/uploaded-files/generate-upload-url/",
    json={
        "filename": "example.jpg",
        "content_type": "image/jpg"
    }
)
response.raise_for_status()

# Step 2: Extract the necessary values from the response.
key = response.json()["key"]
upload_url = response.json()["url"]
upload_post_data = response.json()["post_data"]

# Step 3: Upload the file to our file server (Amazon S3).
with open(LOCAL_PATH_TO_FILE_UPLOAD, "rb") as f:
    response = s3_session.post(upload_url, data=upload_post_data, files={"file": f})
response.raise_for_status()

# Step 4: Register the uploaded file with Vetcove.
response = api_session.post(
    f"{VETCOVE_API_SERVER}/ext/v2/uploaded-files/",
    json={
        "filename": "example.jpg",
        "key": key,
    }
)
response.raise_for_status()
print(f"Created uploaded file with id {response.json()['id']}")
post/ext/v2/uploaded-files/

Request

  • Base URL
    https://connect.vetcove.com
  • URL
    https://connect.vetcove.com/ext/v2/uploaded-files/
  • Auth
    HTTP bearer

Request body

filenamestring required

The filename of the file that was uploaded

keystring required

The key to which the file was uploaded

Response

Created

filenamestring required

The filename of the file that was uploaded

filesizeinteger required

The size of the uploaded file in bytes

idinteger required

The unique identifier of the file that was uploaded

urlstring required

A pre-signed URL good for 1 hour which can be used to download this file

Changes

No recorded changes to this operation across all 1 revision of this API.