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

# Salad Simple Storage Service

> This is a simple HTTP service to allow SaladCloud customers to temporarily upload assets for use in other SaladCloud services. Examples include uploading images for stable diffusion training or inference, audio clips for transcription, etc.

*Last Updated: October 30, 2024*

## Limitations

* Maximum file size is 100MB
* Files will be automatically deleted after 30 days

## Endpoints

See the [API Reference](/reference/s4/) for detailed information on the available endpoints.

### Authorization

Requests to the S4 service must include either:

* A `Salad-Api-Key` header with a valid SaladCloud API key.
* An `Authorization` header with a valid SaladCloud JWT (issued by the
  [Instance Metadata Service](/container-engine/explanation/infrastructure-platform/imds)) as a bearer token.

### Upload a File

#### PUT `/organizations/:organization_name/files/:filename+`

Uploads a file to the specified organization.

**Request Parameters:**

* `organization_name` (string): The name of the organization.
* `filename` (string): The name of the file to upload. This can be a path, and the file will be stored in a directory
  structure based on the path. e.g. `path/to/my/file.tar.gz` will be stored as `path/to/my/file.tar.gz`.

**Example Request:**

```bash theme={null}
curl  -X PUT \
  'https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz' \
  --header 'Salad-Api-Key: YOUR_API_KEY' \
  --form 'mimeType="application/tar+gzip"' \
  --form 'file=@/path/to/my/file.tar.gz'
```

**Example Response:**

```json theme={null}
{
  "url": "https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz"
}
```

**Example Request, Creating Signed URL**

When uploading a file, you can optionally request to sign the url, which will allow you to use the returned url to fetch
the file without needing to include the `Salad-Api-Key` header.

```bash theme={null}
curl  -X PUT \
  'https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz' \
  --header 'Salad-Api-Key: YOUR_API_KEY' \
  --form 'mimeType="application/tar+gzip"' \
  --form 'file=@/path/to/my/file.tar.gz' \
  --form 'sign=true' \
  --signatureExp '86400'
```

**Example Response, Signed URL**

```json theme={null}
{
  "url": "https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz?token=8eb6de1b-b313-4169-8411-39860ebc73ab"
}
```

***

### Download a File

#### GET `/organizations/:organization_name/files/:filename+`

Downloads a file from the specified organization.

**Request Parameters:**

* `organization_name` (string): The name of the organization.
* `filename` (string): The name of the file to download.

**Example Request:**

```bash theme={null}
curl -X GET \
  'https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz' \
  --header 'Salad-Api-Key: YOUR_API_KEY' \
  --output file.tar.gz
```

***

*Last Updated: October 30, 2024*

### Delete a File

#### DELETE `/organizations/:organization_name/files/:filename+`

Deletes a file from the specified organization.

**Request Parameters:**

* `organization_name` (string): The name of the organization.
* `filename` (string): The name of the file to delete.

**Example Request:**

```bash theme={null}
curl -X DELETE \
  'https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz' \
  --header 'Salad-Api-Key: YOUR_API_KEY'
```

***

### List Files

#### GET `/organizations/:organization_name/files`

Lists all files within the specified organization.

**Request Parameters:**

* `organization_name` (string): The name of the organization.

**Example Request:**

```bash theme={null}
curl -X GET \
  'https://storage-api.salad.com/organizations/salad-benchmarking/files' \
  --header 'Salad-Api-Key: YOUR_API_KEY'
```

**Example Response:**

```json theme={null}
{
  "files": [
    {
      "url": "https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz",
      "size": 1024,
      "mimeType": "application/tar+gzip",
      "uploaded": "2021-09-01T12:00:00Z",
      "etag": "1234567890"
    }
  ]
}
```

### Get A Signed Url for a File

#### POST `/organizations/:organization_name/file_tokens/:filename+`

Creates a signed URL for a file in the specified organization.

**Request Parameters:**

* `organization_name` (string): The name of the organization.
* `filename` (string): The name of the file to create a signed URL for.

**Example Request:**

```bash theme={null}
curl -X POST \
  'https://storage-api.salad.com/organizations/salad-benchmarking/file_tokens/path/to/my/file.tar.gz' \
  --header 'Salad-Api-Key: YOUR_API_KEY' \
  --data '{"method": "GET", "expires": 86400}'
```

**Example Response:**

```json theme={null}
{
  "url": "https://storage-api.salad.com/organizations/salad-benchmarking/files/path/to/my/file.tar.gz?token=974360ea-63f7-4db3-9692-72ca5dbae615"
}
```
