> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drime.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Presigned URL

> Get a presigned URL for direct S3 upload

## Overview

Gets a presigned URL for uploading files smaller than 5MB directly to S3/R2 storage. This is more efficient than the direct upload endpoint.

**Upload Flow:**

1. Call this endpoint to get a presigned URL
2. PUT your file to the presigned URL
3. Call `/s3/entries` to register the file in Drime

<Note>
  For files **≥ 5MB**, use the [multipart upload](/api-reference/multipart/create-multipart) flow instead.
</Note>

## Request Body

<ParamField body="filename" type="string" required>
  Original filename
</ParamField>

<ParamField body="mime" type="string" required>
  MIME type of the file
</ParamField>

<ParamField body="size" type="integer" required>
  File size in bytes
</ParamField>

<ParamField body="extension" type="string" required>
  File extension without dot
</ParamField>

<ParamField body="workspaceId" type="integer">
  Workspace ID. Use `0` for personal workspace.
</ParamField>

<ParamField body="relativePath" type="string">
  Folder path for auto-creation
</ParamField>

<ParamField body="parentId" type="integer">
  Parent folder ID
</ParamField>

## Response

<ResponseField name="url" type="string">
  Presigned URL for PUT upload (valid for 1 hour)
</ResponseField>

<ResponseField name="key" type="string">
  S3 key (format: `uploads/{uuid}/{uuid}`)
</ResponseField>

<ResponseField name="acl" type="string">
  Access control (`private`)
</ResponseField>

<ResponseField name="status" type="string">
  Request status (`success`)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  # Step 1: Get presigned URL
  curl -X POST https://app.drime.cloud/api/v1/s3/simple/presign \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "filename": "document.pdf",
      "mime": "application/pdf",
      "size": 87965,
      "extension": "pdf",
      "workspaceId": 0
    }'

  # Step 2: Upload to presigned URL
  curl -X PUT "PRESIGNED_URL" \
    -H "Content-Type: application/pdf" \
    --data-binary @document.pdf
  ```

  ```javascript JavaScript theme={null}
  // Step 1: Get presigned URL
  const presignResponse = await fetch('https://app.drime.cloud/api/v1/s3/simple/presign', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      filename: file.name,
      mime: file.type,
      size: file.size,
      extension: file.name.split('.').pop(),
      workspaceId: 0
    })
  });

  const { url, key } = await presignResponse.json();

  // Step 2: Upload to presigned URL
  await fetch(url, {
    method: 'PUT',
    headers: {
      'Content-Type': file.type
    },
    body: file
  });

  // Step 3: Create file entry (see /s3/entries endpoint)
  ```

  ```python Python theme={null}
  import requests

  # Step 1: Get presigned URL
  presign_response = requests.post(
      'https://app.drime.cloud/api/v1/s3/simple/presign',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      json={
          'filename': 'document.pdf',
          'mime': 'application/pdf',
          'size': 87965,
          'extension': 'pdf',
          'workspaceId': 0
      }
  )

  data = presign_response.json()
  presigned_url = data['url']
  key = data['key']

  # Step 2: Upload to presigned URL
  with open('document.pdf', 'rb') as f:
      requests.put(
          presigned_url,
          headers={'Content-Type': 'application/pdf'},
          data=f
      )

  # Step 3: Create file entry (see /s3/entries endpoint)
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "url": "https://drimestorage.xxx.r2.cloudflarestorage.com/uploads/71ea55f2.../71ea55f2...?X-Amz-Algorithm=AWS4-HMAC-SHA256&...",
    "key": "uploads/71ea55f2-1ba7-46ad-98b7-db487ecac2f6/71ea55f2-1ba7-46ad-98b7-db487ecac2f6",
    "acl": "private",
    "status": "success"
  }
  ```
</ResponseExample>
