Upload file to the Cloud
This document provides an in-depth tutorial on securely uploading files to Connecteam’s cloud using our Attachments API, for future use with the uploaded files in different API endpoints.
Each step includes specific parameters necessary to ensure the file upload is secure, efficient, and integrates smoothly with other platform features.
Step 1: Generate Upload URL
Begin by generating a pre-signed URL to secure the upload process. This URL will only be valid for a short duration, enhancing security.
Endpoint:
POST https://api.connecteam.com/attachments/v1/files/generate-upload-url
Body Parameters:
- fileName (required): Name of the file to be uploaded.
- fileTypeHint: MIME type of the file, e.g.,
image/jpeg
,application/pdf
. - featureType (required): Specifies the application feature associated with the file, such as
chat
.
Example Request:
curl -X POST https://api.connecteam.com/attachments/v1/files/generate-upload-url \
-H 'X-API-KEY: your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"fileName": "example.pdf",
"fileTypeHint": "application/pdf",
"featureType": "chat"
}'
Step 2: Upload Your File
Using the pre-signed URL obtained from the first step, upload your file. This step must be completed within the URL's active timeframe to ensure security.
Use the Pre-signed URL:
curl -X PUT <pre-signed-url> \
-H 'Content-Type: application/pdf' \
-T path_to_your_file/example.pdf
Step 3: Finalize Upload
Once the file is uploaded, finalize the upload process to confirm that the file is stored correctly and associated with the intended feature.
Endpoint:
PUT https://api.connecteam.com/attachments/v1/files/complete-upload/{fileId}
Path Parameters:
- fileId (required): Unique identifier for the uploaded file.
Example Request:
curl -X PUT https://api.connecteam.com/attachments/v1/files/complete-upload/{fileId} \
-H 'X-API-KEY: your_api_key'
Step 4: Get File Metadata
Retrieve detailed information about the uploaded file.
Endpoint:
GET https://api.connecteam.com/attachments/v1/files/{fileId}
Path Parameters:
- fileId (required): Unique identifier for the file.
Example Request:
curl -X GET https://api.connecteam.com/attachments/v1/files/{fileId} \
-H 'X-API-KEY: your_api_key'
Updated 1 day ago