Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Adds a few more examples to the storage Code blocks

Paul Copplestonee42de2eb1840
diff --git a/www/data/products/storage/api-examples.js b/www/data/products/storage/api-examples.js
index 416a1c7ca47..2f822f4739b 100644
--- a/www/data/products/storage/api-examples.js
+++ b/www/data/products/storage/api-examples.js
@@ -3,11 +3,12 @@ export default [
lang: 'js',
title: 'Upload a file',
code: `
-
- const { data, error } = await supabase
- .storage
- .from('avatars-bucket')
- .upload('avatar.png', avatarFile)
+// Upload an image to the "avatars" bucket
+const spaceCat = event.target.files[0]
+const { data, error } = await supabase
+ .storage
+ .from('avatars')
+ .upload('space-cat.png', spaceCat)
@@ -19,10 +20,65 @@ export default [
lang: 'js',
title: 'Download a file',
code: `
- const { data, error } = await supabase
- .storage
- .from('avatars-bucket')
- .download('avatar.png')
+// Download the "space-cat.png" image from the "avatars" bucket
+const { data, error } = await supabase
+ .storage
+ .from('avatars')
+ .download('space-cat.png')
+
+
+
+
+
+
+ `,
+ },
+ {
+ lang: 'js',
+ title: 'List files',
+ code: `
+// List all the files in the "avatars" bucket
+const { data, error } = await supabase
+ .storage
+ .from('avatars')
+ .list()
+
+
+
+
+
+
+ `,
+ },
+ {
+ lang: 'js',
+ title: 'Move and rename files',
+ code: `
+// Move and rename files
+const { data, error } = await supabase
+ .storage
+ .from('avatars')
+ .move('pubic/space-cat.png', 'private/space-cat.png')
+
+
+
+
+
+
+
+ `,
+ },
+ {
+ lang: 'js',
+ title: 'Delete files',
+ code: `
+// Delete a list of files
+const { data, error } = await supabase
+ .storage
+ .from('avatars')
+ .remove([ 'avatar1.png', 'avatar2.png' ])
+
+