本页还没有译文
本页 19 段还没译成한국어,下面显示的是英文原文。Creating Buckets
还没翻译译自英文(supabase.com)本页 19 段都还没译
You can create a bucket using the Supabase Dashboard. Since storage is interoperable with your Postgres database, you can also use SQL or our client libraries. Here we create a bucket called "avatars":
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)
// ---cut---
// Use the JS library to create a bucket.
const { data, error } = await supabase.storage.createBucket('avatars', {
public: true, // default: false
})- Go to the Storage page in the Dashboard.
- Click New Bucket and enter a name for the bucket.
- Click Create Bucket.
-- Use Postgres to create a bucket.
insert into storage.buckets
(id, name, public)
values
('avatars', 'avatars', true);void main() async {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
final storageResponse = await supabase
.storage
.createBucket('avatars');
}try await supabase.storage.createBucket(
"avatars",
options: BucketOptions(public: true)
)supabase.storage.create_bucket(
'avatars',
options={"public": True}
)var bucket = await supabase.Storage.CreateBucket("avatars", new BucketUpsertOptions { Public = true });Restricting uploads
When creating a bucket you can add additional configurations to restrict the type or size of files you want this bucket to contain.
For example, imagine you want to allow your users to upload only images to the avatars bucket and the size must not be greater than 1MB. You can achieve the following by providing allowedMimeTypes and maxFileSize:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)
// ---cut---
// Use the JS library to create a bucket.
const { data, error } = await supabase.storage.createBucket('avatars', {
public: true,
allowedMimeTypes: ['image/*'],
fileSizeLimit: '1MB',
})If an upload request doesn't meet the above restrictions it will be rejected. See File Limits for more information.
AI 翻译查看英文原文