There are two ways to upload Assets from Teleport.
- Teleport uses the standard upload endpoint and adds teleport specific headers
- Teleport uploads to S3 and then registers Asset with FileSpin Cloud for processing
Upload using standard upload endpoint
Use the standard upload API. Pass the below headers:-
X-Teleport-Id- A string that will be captured in asset'supload_sourcemetadata. This is a indexed in opensearch index to allow search.X-Teleport-Asset-Id- Asset ID that Teleport has created and should be used by FileSpin Cloud for the new Asset
Upload to S3
This is not used at present
Get S3 Upload URL
Obtain S3 url to upload a file.
Teleport uses this to upload files. Picker also is expected to use this.
Request
/api/v1/assets/new/content_storage_url
Authentication
API authentication can be as follows:-
- Using
X-FileSpin-Api-Keyin header - Using
upload_keyin query parameters- this is used by Picker, Picker should also pass
picker_hostwhich is the upload hostname obtained from browser
- this is used by Picker, Picker should also pass
- Using JWT via
Authorizationbearer token
Response
{
"asset_id": "04b5efdeb7a04e2c9c4dea15ad45e60b",
"storage": {
"name": "test_video_wildlife.mov",
"url": "https://filespin-bucket.s3.amazonaws.com/",
"fields": {
"key": "originals/04b5efdeb7a04e2c9c4dea15ad45e60b/original/original__test_video_wildlife.mov",
"x-amz-algorithm": "AWS4-HMAC-SHA256",
"x-amz-credential": "AKIATP3RKAPE4JGVPCK5/20240317/eu-west-2/s3/aws4_request",
"x-amz-date": "20240617T184333Z",
"policy": "eyJlcHBpcmF0aW9uIjogIjIwMjQtMDYtMThUMTg6NDM6MzNaIiwgImNvbmRpdGlvbnMiOiBbeyJidWNrZXQiOiAiZmlsZXNwaW4tZGV2In0sIHsia2V5IjogIm9yaWdpbmFscy8wNGI1ZWZkZWI3YTA0ZTJjOWM0ZGVhMTVhZDQ1ZTYwYi9vcmlnaW5hbC9vcmlnaW5hbF9fdGVzdF92aWRlb193aWxkbGlmZS5tb3YifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVRQM1JLQVBFNEpHVlBDSzUvMjAyNDA2MTcvZXUtd2VzdC0yL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAyNDA2MTdUMTg0MzMzWiJ9XX0=",
"x-amz-signature": "31a1ef4dc20e057c79fc66cdbeb20214044dfd76cd6107adc128058e6f0826a2"
},
"protocol": "POST",
"expiry": 86400,
"key": "/originals/04b5efdeb7a04e2c9c4dea15ad45e60b/original/original__test_video_wildlife.mov",
"bucket": "filespin-bucket",
"storage_type": "AMAZON_S3"
}
}
The response contains url and fields. Uploads to S3 can be done to the url as below:-
import requests
url = "https://filespin-bucket.s3.amazonaws.com/"
payload = {'key': 'originals/d6de9bd4334c4440bb18ccfc20683f56/original/original__test.jpg',
'policy': 'eyJleHBpcmF0aW9uIjogIjIwMjQtMDUtMTRUMTY6NDk6MThaIiwgImNvbmRpdGlvbnMiOiBbeyJidWNrZXQiOiAiZmlsZXNwaW4tZGV2In0sIHsia2V5IjogIm9yaWdpbmFscy9kNmRlOWJkNDMzNGM0NDQwYmIxOGNjZmMyMDY4M2Y1Ni9vcmlnaW5hbC9vcmlnaW5hbF9fdGVzdC5qcGcifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVRQM1JLQVBFNEpHVlBDSzUvMjAyNDA1MTMvZXUtd2VzdC0yL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAyNDA1MTNUMTY0OTE4WiJ9XX0=',
'x-amz-signature': '9127ba0a5667a01ddd7e4d02c7267c902e64bcbaea9455616e83a5ae91e6654a',
'x-amz-algorithm': 'AWS4-HMAC-SHA256',
'x-amz-credential': 'AKIATP3RKAPE4JGVPCK5/20240513/eu-west-2/s3/aws4_request',
'x-amz-date': '20240513T164918Z'}
files=[
('file',('test.jpg',open('./test.jpg','rb'),'image/jpeg'))
]
headers = {
'Accept': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
const myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
const formdata = new FormData();
formdata.append("key", "originals/d6de9bd4334c4440bb18ccfc20683f56/original/original__test.jpg");
formdata.append("policy", "eyJleHBpcmF0aW9uIjogIjIwMjQtMDUtMTRUMTY6NDk6MThaIiwgImNvbmRpdGlvbnMiOiBbeyJidWNrZXQiOiAiZmlsZXNwaW4tZGV2In0sIHsia2V5IjogIm9yaWdpbmFscy9kNmRlOWJkNDMzNGM0NDQwYmIxOGNjZmMyMDY4M2Y1Ni9vcmlnaW5hbC9vcmlnaW5hbF9fdGVzdC5qcGcifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVRQM1JLQVBFNEpHVlBDSzUvMjAyNDA1MTMvZXUtd2VzdC0yL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAyNDA1MTNUMTY0OTE4WiJ9XX0=");
formdata.append("x-amz-signature", "9127ba0a5667a01ddd7e4d02c7267c902e64bcbaea9455616e83a5ae91e6654a");
formdata.append("x-amz-algorithm", "AWS4-HMAC-SHA256");
formdata.append("x-amz-credential", "AKIATP3RKAPE4JGVPCK5/20240513/eu-west-2/s3/aws4_request");
formdata.append("x-amz-date", "20240513T164918Z");
formdata.append("file", fileInput.files[0], "test.jpg");
const requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
fetch("https://filespin-bucket.s3.amazonaws.com/", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Register Asset after S3 upload
Once a file is uploaded to S3 using the URL obtained above, it must be registered with Cloud in order for Cloud backend to ingest and process it.
Teleport uses this to register an asset with SaaS after the asset is uploaded to directly S3. Picker also is expected to use this.
Request
/api/v1/assets/new/register_asset
Request Headers (Optional)
Teleport is expected to send the below headers so that Cloud can selectively invoke addons and conversions that Teleport does not process for an asset. This prevents double processing of asset in Teleport and Cloud.
X-FileSpin-Teleport-Addons- this should contain the Addon keys for addons deployed in Teleport. Keys should be space separated likeFACE_RECOGNITION SCENE_CLASSIFICATION- If VIDEO_TRANSFORMATION addon is deployed in Teleport, an additional header should be sent as below
X-FileSpin-Teleport-Conversions - this should contain space separated transcode keys like 480p-video 720p-video
Request Body
{
"asset_id": "44d83dee0c614f559fa4b09ac0b85388",
"size": 102400,
"checksum": "dba882662d4b0498bd4efb922c06015e",
"upload_time": "2024-06-17T08:12:55Z",
"upload_started_at": "2024-06-17T08:12:56Z",
"upload_completed_at": "2024-06-17T08:12:58Z",
"service_data": {
"app": "TELEPORT",
"deployment_data": {
"client": "DEFAULT",
"location": "DEFAULT"
},
"network_bandwidth": 12345,
"build": "VERSION_1.0_BUILD_0.1"
}
}
upload_timeis the time asset was added to Teleport (stand-in for Asset Upload Time defined in Asset Data Response format)clientshould be set to "TELEPORT" in Teleport otherwise should be "DEFAULT"locationshould be set based on Teleport.envotherwise set to "DEFAULT"buildshould be set based onVERSIONin.envof Teleport
Response
HTTP 2xx
Update metadata for Teleport
Teleport uses the public data update API to update asset metadata. In addition to the API key, Teleport should send the below headers in the API request
Request Headers
Teleport is expected to send the below headers so that Cloud can selectively invoke addons and conversions that Teleport does not process for an asset. This prevents double processing of asset in Teleport and Cloud.
X-FileSpin-Teleport-Addons- this should contain the Addon keys for addons deployed in Teleport. Keys should be space separated likeFACE_RECOGNITION SCENE CLASSIFICATION- If VIDEO_TRANSFORMATION addon is deployed in Teleport, an additional header should be sent as below
X-FileSpin-Teleport-Conversions - this should contain space separated transcode keys like 480p-video 720p-video