Create a bucket
createBucket requires name and location. You can also set granular configurations such as public access, accepted file types, file size limit, and attributes (custom metadata). Buckets can also be created through the console.
const result = await client.storage.createBucket({ name: 'avatars', location: 'weur', public: false, allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp'], fileSizeLimit: 5 * 1024 * 1024, attributes: { category: 'profile-images' }}) if (result.error) { throw result.error} console.log(result.data)Bucket names
A bucket name identifies the bucket within a Jupiter project. Object operations use the bucket name together with an object key to locate an object.
The bucket name and location are selected when the bucket is created. Other bucket settings can be changed later.
Location
The location determines where the bucket data is stored. Choose the location closest to the users or systems that will access the objects most often. A bucket location is selected during creation and cannot be changed through the bucket update operation.
| Region string | Location |
|---|---|
| wnam | Western North America |
| enam | Eastern North America |
| weur | Western Europe |
| eeur | Eastern Europe |
| apac | Asia Pacific |
| oc | Oceania |
Public and private buckets
The public setting controls whether objects in the bucket are publicly accessible. Set public to false for private application data and enforce access with Jupiter Auth and Security Policies. Set it to true only when the stored objects are intended to be publicly accessible.
File size limit
The maximum size of an object that can be uploaded to the bucket, in bytes. If an a limit is configured, larger objects will be rejected
The default value is 0, that means no limit.
Allowed MIME types
You can restrict the mime types that can be uploaded to the bucekt. For example, a bucket for profile pics can accept image/jpeg, image/png, and image/webp while rejecting other content types.
An empty array means the bucket does not restrict uploads by MIME type.
Attributes
attributes stores the custom metadata for this bucket as a json object. Its useful for policies (for example adding a premium_tier_only: true) and custom logic.
Bucket attributes apply to the bucket, objects have their own attributes set separately.