HomeGuidesAPI Reference
Log In
Guides

Submit files

This documentation outlines the process for securely uploading files directly to an Amazon S3 bucket using a POST Presigned URL.



1. Understanding the Presigned URL Response

The endpoint submit-files provides a structured JSON response containing the necessary information to perform the upload. The example below shows the structure for a single file upload.

FieldDescription
fileNameThe desired name of the file to be uploaded.
spektrDataFieldAn internal application-specific label for the file.
urlThe base URL for the S3 bucket endpoint where the file will be posted.
fieldsA dictionary of required form fields that must be included in the POST request body.

Example Response Structure:

[
    {
        "fileName": "document.png",
        "url": "https://url.amazonaws.com/",
        "fields": {
            "key": "internal_key",
            "X-Amz-Signature": "...",
            "Policy": "...",
            "X-Amz-Algorithm": "..." // ... all other required AWS authentication fields
        }
    }
]


2. Upload Constraints

Maximum File Size: The size of the file being uploaded must not exceed 15 MB.


3. Executing the File Upload

The file upload is performed using an HTTP POST request to the provided url. The request must be submitted as multipart/form-data and include all fields from the fields object, plus the file itself.

Request Details

  • Method: POST
  • Target URL: The url from the JSON response.
  • Content Type: multipart/form-data

Form Data Fields

The POST request body must contain the following parts in the specified order:

  1. All key-value pairs from the fields object.
  2. The file content itself. The form field name for the file must be file This must be the final field in the form-data submit payload.

Example request (Conceptual cURL)

curl -v -X POST \
  'https://example_url.amazonaws.com/' \
  -H 'Content-Type: multipart/form-data' \
  -F 'key=internal_key.png' \
  -F 'bucket=spektr-...' \
  -F 'X-Amz-Algorithm=AWS4-HMAC-SHA256' \
  -F 'X-Amz-Credential=...' \
  -F 'X-Amz-Date=20251208T110600Z' \
  -F 'X-Amz-Security-Token=...' \
  -F 'Policy=eyJleHBpcmF0aW9uIjo...' \
  -F 'X-Amz-Signature=...' \
  -F 'file=@/path/to/your/document.png'

Success/Failure

Success: A successful upload will typically result in a 204 No Content HTTP status code from S3.

Failure: Failures usually result in an XML-formatted error message from S3 (e.g., 400 Bad Request, 403 Forbidden). Common causes include missing or invalid form fields, an expired presigned URL, or exceeding the 15 MB file size limit. Link with Error response