Skip to main content

File Upload - Presigned URL

POST 

/api/inspect/v1/file/upload/presigned

This endpoint generates a presigned URL that allows users to upload a file directly to the cloud storage service. The presigned URL is valid for 15 minutes and must be used within this timeframe to upload the file. The response will return a fileID and the presigned URL. Ensure that the Content-Type header in the upload request matches the contentType provided in the request body when generating the presigned URL.

Here is an example of how to use the presigned URL to upload a file using curl:

curl -X PUT -H "Content-Type: image/png" --upload-file /path/to/your/file.png "https://your-presigned-url"

This method is ideal for large file uploads, as the file is uploaded directly to cloud storage without passing through the backend. Be sure to follow up with a request to mark the file as uploaded using the Complete File Upload endpoint after a successful upload.

Request

Body

required

    size int64required

    The size of the file in bytes. This ensures that the file size falls within any limits that the system might have for file uploads.

    assetID uuidrequired

    The unique identifier (UUID) of the asset to which the uploaded file belongs. This helps link the uploaded file to a specific asset for future reference.

    contentType stringrequired

    The MIME type of the file to be uploaded (e.g., image/png, application/pdf). This value must be included when requesting a presigned URL and should match the Content-Type header used when uploading the file via the presigned URL.

    hash stringrequired

    The SHA256 hash of the file, encoded in base64. This hash is used to verify the integrity of the file during the upload process. By providing the hash, the system can check that the uploaded file matches the original file.

    Example of calculating the SHA256 hash in base64 on Linux:

    sha256sum /path/to/your/file.png | awk '{print $1}' | xxd -r -p | base64

    This command will output the SHA256 hash of the file and convert it into base64, which should be passed as the hash value.

    name stringrequired

    The original name of the file. This helps track and manage files by their original names in the cloud system.

Responses

200 OK. The file has already been uploaded, and only the file's unique identifier (id) is returned. The response includes the following data:

Schema

    data

    Details of the uploaded file.

    id uuid

    The unique identifier (UUID) assigned to the uploaded file. This can be used to reference the file in future operations, such as creating spot attachment or marking it as fully uploaded or retrieving it later.

Loading...