Upload credential struct returned by upload_credential/3 and upload_credential/4.
Fields
| Field | Type | Description |
|---|
uptoken | String.t() | nil | Qiniu CDN upload token (nil for S3/CloudFront) |
presigned_url | String.t() | nil | S3/OSS presigned URL or CloudFront signed URL |
res_key | String.t() | Resource key (file path) |
headers | %{String.t() => String.t()} | Headers to send with PUT; defaults to %{} |
endpoint | String.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