From 589b69f71fbe69a67cc9f35f6fea1fef898075e7 Mon Sep 17 00:00:00 2001 From: Inian Date: Tue, 11 Apr 2023 00:11:01 +0800 Subject: [PATCH] chore: update storage docs --- spec/supabase_js_v2.yml | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml index b3931572bca..581272785dd 100644 --- a/spec/supabase_js_v2.yml +++ b/spec/supabase_js_v2.yml @@ -4490,7 +4490,11 @@ functions: ```js const { data, error } = await supabase .storage - .createBucket('avatars', { public: false }) + .createBucket('avatars', { + public: false, + allowedMimeTypes: ['image/png'], + fileSizeLimit: 1024 + }) ``` - id: empty-bucket @@ -4516,7 +4520,7 @@ functions: $ref: '@supabase/storage-js.packages/StorageBucketApi.default.updateBucket' notes: | - RLS policy permissions required: - - `buckets` table permissions: `update` + - `buckets` table permissions: `select` and `update` - `objects` table permissions: none - Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works examples: @@ -4527,7 +4531,11 @@ functions: ```js const { data, error } = await supabase .storage - .updateBucket('avatars', { public: false }) + .updateBucket('avatars', { + public: false, + allowedMimeTypes: ['image/png'], + fileSizeLimit: 1024 + }) ``` - id: delete-bucket @@ -4555,7 +4563,7 @@ functions: notes: | - RLS policy permissions required: - `buckets` table permissions: none - - `objects` table permissions: `insert` + - `objects` table permissions: only `insert` when you are uploading new files and `select`, `insert` and `update` when you are upserting files - Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works - For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Upload file using `ArrayBuffer` from base64 file data instead, see example below. examples: @@ -4608,7 +4616,6 @@ functions: .from('avatars') .update('public/avatar1.png', avatarFile, { cacheControl: '3600', - // Overwrite file if it exists upsert: true }) ``` @@ -4733,6 +4740,26 @@ functions: .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60) ``` + - id: from-create-upload-signed-url + title: from.createUploadSignedUrl() + $ref: '@supabase/storage-js.packages/StorageFileApi.default.createUploadSignedUrl' + notes: | + - RLS policy permissions required: + - `buckets` table permissions: none + - `objects` table permissions: `select` + - Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works + examples: + - id: create-signed-urls + name: Create Signed URLs + isSpotlight: true + code: | + ```js + const { data, error } = await supabase + .storage + .from('avatars') + .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60) + ``` + - id: from-get-public-url title: from.getPublicUrl() $ref: '@supabase/storage-js.packages/StorageFileApi.default.getPublicUrl' @@ -4812,6 +4839,7 @@ functions: transform: { width: 100, height: 100, + quality: 80 } }) ```