Skip to main content
GET
https://cdn.sacul.cloud
/
{bucketName}
/
presigned
/
{filepath}
Generate Presigned URL
curl --request GET \
  --url https://cdn.sacul.cloud/{bucketName}/presigned/{filepath} \
  --header 'Authorization: <authorization>'
{
  "success": true,
  "presignedUrl": "<string>",
  "bucketName": "<string>",
  "key": "<string>",
  "expiresIn": 123,
  "expiresAt": "<string>"
}
Presigned URLs allow you to grant temporary access for uploading files directly to your bucket without exposing your API credentials to the client.

Benefits

  • Security: Your API key remains server-side; the client only receives a temporary URL.
  • Performance: Files transfer directly to the storage, reducing load on your backend.
  • Control: URLs expire automatically and are strictly scoped to the specific file path.

Query Headers

Authorization
string
required
Bearer token for authentication (e.g., Bearer <your-api-key>).

Query Parameters

bucketName
string
required
The name of the target bucket.
filepath
string
required
The destination path for the file (e.g., uploads/avatar.jpg).
expiresIn
integer
default:"3600"
Expiration time in seconds (max: 3600).

Response

success
boolean
Indicates if the generation was successful.
presignedUrl
string
The URL to use for the PUT request.
bucketName
string
The bucket name.
key
string
The specific key (path) for the file.
expiresIn
integer
Duration in seconds until expiration.
expiresAt
string
ISO timestamp of when the URL will expire.

Usage Example

1. Generate the URL (Server-side)

First, your backend requests a presigned URL.
curl -X GET https://cdn.sacul.cloud/my-bucket/presigned/users/123/avatar.png?expiresIn=300 \
  -H "Authorization: Bearer <your-api-key>"

2. Upload the File (Client-side)

Once your frontend receives the presignedUrl, use a PUT request to upload the file.
// Example: Uploading a file from an input element
const uploadFile = async (file) => {
  // 1. Fetch the presigned URL from your backend (which calls the sCloud API)
  const response = await fetch('/api/get-upload-url'); 
  const { presignedUrl } = await response.json();

  // 2. Direct upload to sCloud using the presigned URL
  await fetch(presignedUrl, {
    method: 'PUT',
    body: file,
    headers: {
      'Content-Type': file.type // Ensure Content-Type matches the file
    }
  });
};