Skip to content

Generate the url and form fields used for a presigned s3 post

Description

Generate the url and form fields used for a presigned s3 post

Usage

s3_generate_presigned_post(Bucket, Key, Fields = list(),
Conditions = list(), ExpiresIn = 3600)

Arguments

  • Bucket

(character): The name of the bucket to presign the post to. Note that bucket related conditions should not be included in the Conditions parameter.

  • Key

(character): Key name, optionally add ${filename} to the end to attach the submitted filename. Note that key related conditions and fields are filled out for you and should not be included in the Fields or Conditions parameter.

  • Fields

(list): A list of prefilled form fields to build on top of. Note that if a particular element is included in Fields it will not be automatically added to Conditions; you must specify a condition for it as well.

  • Conditions

(list): A list of conditions to include in the policy. Each element is either a named list for an exact-match condition, e.g. list(acl = "public-read"), or a plain list for an array-style condition, e.g. list("starts-with", "$key", "uploads/") or list("content-length-range", 1, 10485760).

  • ExpiresIn

(numeric): The number of seconds the presigned post is valid for. By default it expires in an hour (3600 seconds).

Value

A list with two elements: url and fields. url is the url to post to. fields is a list of form fields and values to include in the post.

Request syntax

svc$generate_presigned_post(
  Bucket = "string",
  Key = "string",
  Fields = list(),
  Conditions = list(),
  ExpiresIn = 3600
)

Examples

# The following example generates the url and form fields for a presigned
# post that you can give to others so that they can upload a file to an
# S3 bucket without needing AWS credentials.
svc$generate_presigned_post(
  Bucket = "BUCKET_NAME",
  Key = "OBJECT_KEY"
)