@textile/hub > Buckets > getOrCreate
Buckets.getOrCreate() method
Open a new / existing bucket by bucket name and ThreadID (create not required) Replaces open command in older versions.
Signature:
getOrCreate(name: string, options?: GetOrCreateOptions): Promise<GetOrCreateResponse>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | name of bucket |
| options | GetOrCreateOptions |
Returns:
Promise<GetOrCreateResponse>
Remarks
The IPFS protocol and its implementations are still in heavy development. By using Textile, you are acknowledging that you understand there may be risks to storing your content on or using decentralized storage services.
Example
Create a Bucket called "app-name-files"
import { Buckets, UserAuth } from '@textile/hub'
const open = async (auth: UserAuth, name: string) => {
const buckets = Buckets.withUserAuth(auth)
const { root, threadID } = await buckets.getOrCreate(name)
return { buckets, root, threadID }
}