View Source AliyunOpenAPI.Specs.OSS.Object (aliyun_open_api v0.6.0)

Provides object related utils.

Summary

Functions

Presigns a PostObject operation and returns the necessary form data when executing the PostObject operation.

Functions

Link to this function

presign_post_object(config, region, bucket, conditions, seconds_to_expire)

View Source
@spec presign_post_object(
  AliyunOpenAPI.Config.t(),
  String.t(),
  String.t(),
  list(),
  pos_integer()
) :: %{
  policy: String.t(),
  "x-oss-signature-version": String.t(),
  "x-oss-credential": String.t(),
  "x-oss-date": String.t(),
  "x-oss-signature": String.t()
}

Presigns a PostObject operation and returns the necessary form data when executing the PostObject operation.

Read more at:

Adding signature

This implementation has built-in V4 signature support.

V1 signature is not supported.

Examples

config =
  Config.new!(
    access_key_id: "...",
    access_key_secret: "..."
  )

region = "oss-us-west-1"
bucket = "example-bucket"
conditions = [
  ["eq", "$key", "lenna.png"],
  ["eq", "$x-oss-object-acl", "private"],
  ["content-length-range", 1, 1024 * 1024 * 5]
]
seconds_to_expire = 3600

presign_post_object(config, region, bucket, conditions, seconds_to_expire)

# returns:
#
# %{
#   policy: "eyJjb25ka ... jM1OjUxWiJ9",
#   "x-oss-signature-version": "OSS4-HMAC-SHA256",
#   "x-oss-credential": ".../20240519/us-west-1/oss/aliyun_v4_request",
#   "x-oss-date": "20240519T143551Z",
#   "x-oss-signature": "4526fe7c1e9f58f3da7edbfb31758721564f38bfba5cdd3f5d8d5ae67a60c60b"
# }