View Source MoonWeb.Pages.Components.FileInputPage.SimpleS3Upload (Moon v2.89.1)

Dependency-free S3 Form Upload using HTTP POST sigv4 https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html

Summary

Functions

Link to this function

credential(config, expires_at)

View Source
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.

Options

  • :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.

Examples

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)
  )
Link to this function

signature(config, expires_at, encoded_policy)

View Source
Link to this function

signing_key(config, expires_at, service)

View Source