ExOss.UploadCredential (ExOss v1.2.0)

Copy Markdown View Source

Upload credential struct returned by upload_credential/3 and upload_credential/4.

Fields

FieldTypeDescription
uptokenString.t()nilQiniu CDN upload token (nil for S3/CloudFront)
presigned_urlString.t()nilS3/OSS presigned URL or CloudFront signed URL
res_keyString.t()Resource key (file path)
headers%{String.t() => String.t()}Headers to send with PUT; defaults to %{}
endpointString.t()Upload endpoint

S3 Upload

Use presigned_url with a PUT request:

credential = MyApp.Storage.upload_credential("bucket", "path/file.jpg", 3600)
Req.put!(credential.presigned_url, body: file_content, headers: credential.headers)

Qiniu CDN Upload

Use uptoken with Qiniu's form upload API:

credential = MyApp.Storage.upload_credential("bucket", "path/file.jpg", 3600)
# POST to credential.endpoint with token and file

Summary

Types

t()

@type t() :: %ExOss.UploadCredential{
  endpoint: String.t(),
  headers: %{required(String.t()) => String.t()},
  presigned_url: String.t() | nil,
  res_key: String.t(),
  uptoken: String.t() | nil
}