View Source SimpleS3Upload (Claper v1.7.0)

Dependency-free S3 Form Upload using HTTP POST sigv4

Link to this section Summary

Link to this section Functions

Link to this function

sign_form_upload(config, bucket, opts)

View Source

Signs a form upload.

The configuration is a map which must contain the following keys:

  • :region - The AWS region, such as "us-east-1"
  • :access_key_id - The AWS access key id
  • :secret_access_key - The AWS secret access key

Returns a map of form fields to be used on the client via the JavaScript FormData API.



  • :key - The required key of the object to be uploaded.
  • :max_file_size - The required maximum allowed file size in bytes.
  • :content_type - The required MIME type of the file to be uploaded.
  • :expires_in - The required expiration time in milliseconds from now before the signed upload expires.



config = %{
  region: "us-east-1",
  access_key_id: System.fetch_env!("AWS_ACCESS_KEY_ID"),
  secret_access_key: System.fetch_env!("AWS_SECRET_ACCESS_KEY")

{:ok, fields} =
  SimpleS3Upload.sign_form_upload(config, "my-bucket",
    key: "public/my-file-name",
    content_type: "image/png",
    max_file_size: 10_000,
    expires_in: :timer.hours(1)