Uplo
Services

AWS S3

Installation

Install S3 service

npm i @uplo/service-s3

Add service to Uplo

import { createS3Service } from '@uplo/service-s3'

const uplo = createUplo({
  services: {
    s3: createS3Service({
      isPublic: false,
      region: process.env.AWS_REGION,
      bucket: process.env.AWS_BUCKET,
      accessKeyId: '*****',
      secretAccessKey: '*****',
    }),
  },
})

Options

  • bucket (required): Your bucket name where to store objects.
  • accessKeyId (required): Provide Access Key ID from your service credentials
  • secretAccessKey (required): Provide Secret Access Key from your service credentials
  • region = 'us-east-1: Provide your service region
  • isPublic = false: Specify a bucket ACL
  • endpoint: You can provide a custom endpoint if you have a custom service
  • publicUrl: Base URL for public files (e.g. CDN or custom domain). Defaults to the bucket URL
  • acl = true: Send object ACL on uploads. Set false for providers without ACL support
  • requestChecksumCalculation = 'WHEN_REQUIRED', responseChecksumValidation = 'WHEN_REQUIRED': AWS SDK checksum behavior. The SDK default (WHEN_SUPPORTED) signs a checksum of an empty body into direct upload URLs, so uploads fail
  • storagePath: Default file path in the bucket for attachments without their own storagePath. See Storage path

Direct Upload

CORS

This is example CORS configuration for direct uploads.

[
  {
    "AllowedHeaders": ["*"],
    "AllowedMethods": ["PUT"],
    "AllowedOrigins": ["https://www.example.com"],
    "ExposeHeaders": ["Origin", "Content-Type", "Content-MD5", "Content-Disposition"],
    "MaxAgeSeconds": 3600
  }
]

Permissions

Before attaching a direct upload, Uplo reads the file with a HEAD request, which needs s3:GetObject. Without s3:ListBucket, S3 answers 403 instead of 404 for a missing file, so the attach fails with an access error instead of BlobNotUploadedError.

On this page