Compressor APIStorageAWS S3

Storage - AWS S3

Integrate AWS S3 with Compressor API using our Storage Connectors system. This approach keeps your AWS credentials secure within your Compressor Account, requiring only a connector reference ID in your API calls.

Authentication

Authentication is handled exclusively through Storage Connectors. Create a connector in your Compressor Account dashboard, then reference it using its unique identifier:

{
    "store": {
        "id": "your-connector-id"
    }
}

Configuration Options

ParameterTypeRequiredDetails
bucketStringYesTarget S3 bucket name.
regionStringYesAWS region hosting your bucket.
pathStringNoObject destination path (omit leading slash). Defaults to root.
aclStringNoObject access permissions. Default: public-read.
classStringNoStorage tier: standard, reduced-redundancy, standard-ia, onezone-ia, intelligent-tiering, glacier, deep-archive. Default: standard.
metadataHashNoCustom S3 Metadata.
headersHashNoCustom HTTP Headers: Expires, Cache-Control, Content-Type, Content-Encoding, Content-Language, Content-Disposition.
tagsHashNoCustom S3 Tags.

Example Configuration

{
  "store": {
    "id": "your-connector-id",
    "bucket": "images",
    "region": "eu-central-1",
    "path": "assets/image.jpg",
    "acl": "public-read",
    "metadata": {
      "key": "value"
    },
    "headers": {
      "Cache-Control": "max-age=2592000000"
    },
    "tags": {
      "key": "value"
    }
  }
}

Implementation Example

Below is a complete API request demonstrating AWS S3 storage integration:

curl https://api.compressor.app/1.0/fetch \
  -X POST \
  -u your-api-key: \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.website.com/image.jpg",
    "image": {
      "resize": {
        "width": 640,
        "height": 480,
        "mode": "fit"
      }
    },
    "store": {
      "id": "your-connector-id",
      "bucket": "my-bucket",
      "region": "eu-central-1",
      "path": "processed/image.jpg",
      "headers": {
        "Cache-Control": "max-age=2592000000"
      }
    }
  }'

API Response

Successful requests return the S3 object URL in the response.

{
  "id": "38a8bb5e-7b50-4a22-a0a6-b9602fccb225",
  "url": "https://bucket-name.s3.eu-central-1.amazonaws.com/assets/image.jpg",
  "input": {
    "name": "image.jpg",
    "type": "image",
    ...
  },
  "output": {
    "name": "image.jpg",
    "type": "image",
    ...
  }
}

IAM Permissions Requirements

When setting up your connector credentials, verify that the associated IAM user or role has appropriate permissions. Your bucket policy must authorize these operations:

{
  "Statement": {
    "Effect": "Allow",
    "Action": [
      "s3:PutObject",
      "s3:PutObjectAcl"
    ],
    "Resource": [
      "arn:aws:s3:::my-bucket/*"
    ]
  }
}
On this page