Files
supabase/apps/docs/content/guides/storage/uploads/standard-uploads.mdx
Kody JacksonandClaude Sonnet 5.5 39cf54f3c4 docs: add cross-links to related guides and references (#53384)
## What

Adds internal cross-links where a page mentions a product, feature, or
concept that has its own canonical page. This PR covers docs guides
under `apps/docs/content/guides`, excluding the shared partials
(separate PR).

## How links were chosen

- One canonical target per keyword, preferring docs guides over
marketing or blog pages for docs content.
- Only plain prose mentions: nothing inside headings, code, frontmatter,
existing links, or UI labels.
- One link per sentence, and no second link to the same target on a
page.

## Testing

- Prettier passes on all changed files.
- Not yet run: docs build and internal link test, KB build. Draft until
those are checked.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 09:59:49 -06:00

462 lines
11 KiB
Plaintext

---
id: 'standard-uploads'
title: 'Standard Uploads'
description: 'Learn how to upload files to Supabase Storage.'
subtitle: 'Learn how to upload files to Supabase Storage.'
sidebar_label: 'Uploads'
---
## Uploading
The standard file upload method is ideal for small files that are not larger than 6MB.
You implement file uploads with the [supabase-js](/docs/reference/javascript/introduction) SDK using the traditional `multipart/form-data` format. Here's an example of how to upload a file using the standard upload method:
<Admonition type="note">
Though you can upload up to 5GB files using the standard upload method, we recommend using [TUS Resumable Upload](/docs/guides/storage/uploads/resumable-uploads) for uploading files greater than 6MB in size for better reliability.
</Admonition>
<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="js"
queryGroup="language"
>
<TabPanel id="js" label="JavaScript">
```javascript
// @noImplicitAny: false
// ---cut---
import { createClient } from '@supabase/supabase-js'
// Create Supabase client
const supabase = createClient('your_project_url', 'your_supabase_api_key')
// Upload file using standard upload
async function uploadFile(file) {
const { data, error } = await supabase.storage.from('bucket_name').upload('file_path', file)
if (error) {
// Handle error
} else {
// Handle success
}
}
```
</TabPanel>
<$Show if="sdk:dart">
<TabPanel id="dart" label="Dart">
```dart
// Upload file using standard upload
Future<void> uploadFile(File file) async {
await supabase.storage.from('bucket_name').upload('file_path', file);
}
```
</TabPanel>
</$Show>
<$Show if="sdk:swift">
<TabPanel id="swift" label="Swift">
```swift
import Supabase
// Create Supabase client
let supabase = SupabaseClient(supabaseURL: URL(string: "your_project_url")!, supabaseKey: "your_supabase_api_key")
try await supabase.storage.from("bucket_name").upload(path: "file_path", file: file)
```
</TabPanel>
</$Show>
<$Show if="sdk:kotlin">
<TabPanel id="kotlin" label="Kotlin">
```kotlin
supabase.storage.from("bucket_name").upload("file_path", bytes)
//Or on JVM/Android: (This will stream the data from the file to supabase)
supabase.storage.from("bucket_name").upload("file_path", file)
```
</TabPanel>
</$Show>
<$Show if="sdk:python">
<TabPanel id="python" label="Python">
```python
response = supabase.storage.from_('bucket_name').upload('file_path', file)
```
</TabPanel>
</$Show>
<$Show if="sdk:csharp">
<TabPanel id="csharp" label="C#">
```c#
await supabase.Storage.From("bucket_name").Upload("local_file_path", "file_path");
```
</TabPanel>
</$Show>
<TabPanel id="curl" label="cURL">
```bash
curl -X POST "https://{your_project_ref}.supabase.co/storage/v1/object/{bucket_name}/{file_path}" \
-H "apikey: {your_anon_key}" \
-H "Authorization: Bearer {your_jwt_token}" \
--data-binary "@/local/path/to/your/file.ext"
```
</TabPanel>
</Tabs>
## Overwriting files
When uploading a file to a path that already exists, the default behavior is to return a `400 Asset Already Exists` error.
If you want to overwrite a file on a specific path you can set the `upsert` options to `true` or using the `x-upsert` header.
<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="js"
queryGroup="language"
>
<TabPanel id="js" label="JavaScript">
```javascript
import { createClient } from '@supabase/supabase-js'
const file = new Blob()
// ---cut---
// Create Supabase client
const supabase = createClient('your_project_url', 'your_supabase_api_key')
await supabase.storage.from('bucket_name').upload('file_path', file, {
upsert: true,
})
```
</TabPanel>
<$Show if="sdk:dart">
<TabPanel id="dart" label="Dart">
```dart
await supabase.storage.from('bucket_name').upload(
'file_path',
file,
fileOptions: const FileOptions(upsert: true),
);
```
</TabPanel>
</$Show>
<$Show if="sdk:swift">
<TabPanel id="swift" label="Swift">
```swift
import Supabase
// Create Supabase client
let supabase = SupabaseClient(supabaseURL: URL(string: "your_project_url")!, supabaseKey: "your_supabase_api_key")
try await supabase.storage.from("bucket_name")
.upload(
path: "file_path",
file: file,
options: FileOptions(
upsert: true
)
)
```
</TabPanel>
</$Show>
<$Show if="sdk:kotlin">
<TabPanel id="kotlin" label="Kotlin">
```kotlin
supabase.storage.from("bucket_name").upload("file_path", bytes) {
upsert = true
}
```
</TabPanel>
</$Show>
<$Show if="sdk:python">
<TabPanel id="python" label="Python">
```python
response = supabase.storage.from_('bucket_name').upload('file_path', file, {
'upsert': 'true',
})
```
</TabPanel>
</$Show>
<$Show if="sdk:csharp">
<TabPanel id="csharp" label="C#">
```c#
await supabase.Storage
.From("bucket_name")
.Upload("local_file_path", "file_path", new FileOptions { Upsert = true });
```
</TabPanel>
</$Show>
<TabPanel id="curl" label="cURL">
```bash
curl -X POST "https://{your_project_ref}.supabase.co/storage/v1/object/{bucket_name}/{file_path}" \
-H "apikey: {your_anon_key}" \
-H "Authorization: Bearer {your_jwt_token}" \
-H "x-upsert: true" \
--data-binary "@/local/path/to/your/file.ext"
```
</TabPanel>
</Tabs>
We do advise against overwriting files when possible, as our Content Delivery Network will take sometime to propagate the changes to all the edge nodes leading to stale content.
Uploading a file to a new path is the recommended way to avoid propagation delays and stale content.
## Content type
By default, Storage will assume the content type of an asset from the file extension. If you want to specify the content type for your asset, pass the `contentType` option during upload.
<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="js"
queryGroup="language"
>
<TabPanel id="js" label="JavaScript">
```javascript
import { createClient } from '@supabase/supabase-js'
const file = new Blob()
// ---cut---
// Create Supabase client
const supabase = createClient('your_project_url', 'your_supabase_api_key')
await supabase.storage.from('bucket_name').upload('file_path', file, {
contentType: 'image/jpeg',
})
```
</TabPanel>
<$Show if="sdk:dart">
<TabPanel id="dart" label="Dart">
```dart
await supabase.storage.from('bucket_name').upload(
'file_path',
file,
fileOptions: const FileOptions(contentType: 'image/jpeg'),
);
```
</TabPanel>
</$Show>
<$Show if="sdk:swift">
<TabPanel id="swift" label="Swift">
```swift
import Supabase
// Create Supabase client
let supabase = SupabaseClient(supabaseURL: URL(string: "your_project_url")!, supabaseKey: "your_supabase_api_key")
try await supabase.storage.from("bucket_name")
.upload(
path: "file_path",
file: file,
options: FileOptions(
contentType: "image/jpeg"
)
)
```
</TabPanel>
</$Show>
<$Show if="sdk:kotlin">
<TabPanel id="kotlin" label="Kotlin">
```kotlin
supabase.storage.from("bucket_name").upload("file_path", bytes) {
contentType = ContentType.Image.JPEG
}
```
</TabPanel>
</$Show>
<$Show if="sdk:python">
<TabPanel id="python" label="Python">
```python
response = supabase.storage.from_('bucket_name').upload('file_path', file, {
'content-type': 'image/jpeg',
})
```
</TabPanel>
</$Show>
<$Show if="sdk:csharp">
<TabPanel id="csharp" label="C#">
```c#
await supabase.Storage
.From("bucket_name")
.Upload(
"local_file_path",
"file_path",
new FileOptions { ContentType = "image/jpeg" },
inferContentType: false);
```
</TabPanel>
</$Show>
<TabPanel id="curl" label="cURL">
```bash
curl -X POST "https://{your_project_ref}.supabase.co/storage/v1/object/{bucket_name}/{file_path}" \
-H "apikey: {your_anon_key}" \
-H "Authorization: Bearer {your_jwt_token}" \
-H "Content-Type: {Content-Type}" \
--data-binary "@/local/path/to/your/file.ext"
```
</TabPanel>
</Tabs>
## Concurrency
When two or more clients upload a file to the same path, the first client to complete the upload will succeed and the other clients will receive a `400 Asset Already Exists` error.
If you provide the `x-upsert` header the last client to complete the upload will succeed instead.
## Presigned uploads
Standard uploads also support using signed upload tokens to create time-limited URLs that you can share with your users. Create the signed URL by invoking the `createSignedUploadUrl` method on the SDK, then pass the returned token to `uploadToSignedUrl` to complete the upload.
<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="javascript"
queryGroup="language"
>
<TabPanel id="javascript" label="JavaScript">
```typescript
// Create a signed upload URL
const { data } = await supabase.storage.from('bucket_name').createSignedUploadUrl('file_path')
// Upload to the signed URL
const { error } = await supabase.storage
.from('bucket_name')
.uploadToSignedUrl('file_path', data.token, file)
```
</TabPanel>
<$Show if="sdk:dart">
<TabPanel id="dart" label="Dart">
```dart
// Create a signed upload URL
final response = await supabase.storage.from('bucket_name').createSignedUploadUrl('file_path');
// Upload to the signed URL
await supabase.storage.from('bucket_name').uploadToSignedUrl('file_path', response.token, file);
```
</TabPanel>
</$Show>
<$Show if="sdk:swift">
<TabPanel id="swift" label="Swift">
```swift
// Create a signed upload URL
let signedUrl = try await supabase.storage.from("bucket_name").createSignedUploadURL(path: "file_path")
// Upload to the signed URL
try await supabase.storage.from("bucket_name")
.uploadToSignedURL(path: "file_path", token: signedUrl.token, data: file)
```
</TabPanel>
</$Show>
<$Show if="sdk:kotlin">
<TabPanel id="kotlin" label="Kotlin">
```kotlin
// Create a signed upload URL
val signedUrl = supabase.storage.from("bucket_name").createSignedUploadUrl("file_path")
// Upload to the signed URL
supabase.storage.from("bucket_name").uploadToSignedUrl("file_path", signedUrl.token, bytes)
```
</TabPanel>
</$Show>
<$Show if="sdk:python">
<TabPanel id="python" label="Python">
```python
# Create a signed upload URL
response = supabase.storage.from_('bucket_name').create_signed_upload_url('file_path')
# Upload to the signed URL
with open('local_file_path', 'rb') as f:
supabase.storage.from_('bucket_name').upload_to_signed_url(
path='file_path',
token=response.token,
file=f,
)
```
</TabPanel>
</$Show>
<$Show if="sdk:csharp">
<TabPanel id="csharp" label="C#">
```c#
// Create a signed upload URL
var signedUrl = await supabase.Storage.From("bucket_name").CreateUploadSignedUrl("file_path");
// Upload to the signed URL
await supabase.Storage.From("bucket_name").UploadToSignedUrl("local_file_path", signedUrl);
```
</TabPanel>
</$Show>
<TabPanel id="curl" label="cURL">
```bash
# Create a signed upload URL
curl -X POST "https://{your_project_ref}.supabase.co/storage/v1/object/upload/sign/{bucket_name}/{file_path}" \
-H "apikey: {your_anon_key}" \
-H "Authorization: Bearer {your_jwt_token}"
# Upload to the signed URL, using the token returned above
curl -X PUT "https://{your_project_ref}.supabase.co/storage/v1/object/upload/sign/{bucket_name}/{file_path}?token={token}" \
--data-binary "@/local/path/to/your/file.ext"
```
</TabPanel>
</Tabs>
### Revoke signed URLs
You can't revoke individual signed URLs. To revoke all signed URLs, rotate your project's URL signing key, and then revoke the previous key. For more information, see [URL Signing Keys](/docs/guides/storage/security/signing-keys).