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:
- Call the generate-upload-url endpoint to initiate an upload.
- POST your file to the returned URL, including the returned form data.
- 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 URLhttps://connect.vetcove.com
- URLhttps://connect.vetcove.com/ext/v2/uploaded-files/
- AuthHTTP bearer
Request body
Response
Created
Changes
No recorded changes to this operation across all 1 revision of this API.