Skip to main content

getOrCreateBucket()

EXPERIMENTAL

在你的 GCP 项目中为 Remotion Cloud Run 创建一个 Cloud Storage 存储桶。如果已经存在,则会返回现有的存储桶。

🌐 Creates a Cloud Storage bucket for Remotion Cloud Run in your GCP project. If one already exists, it will get returned instead.

每个区域只需要1个存储桶,Remotion Cloud Run 就可以正常运行。

import {getOrCreateBucket} from '@remotion/cloudrun';

const {bucketName, alreadyExisted} = await getOrCreateBucket({
  region: 'us-east1',
});

console.log(bucketName); // "remotioncloudrun-32df3p"

参数

🌐 Arguments

一个具有以下属性的对象:

🌐 An object with the following properties:

region

你希望创建存储桶的 GCP 区域

🌐 The GCP region which you want to create a bucket in.

updateBucketState?

回调函数,返回操作的状态(字符串)。由 CLI 使用以提供进度更新。状态将是以下之一;

🌐 Callback function that returns a state (string) of operation. Used by the CLI to provide a progress update. State will be one of the following;

  • 检查已有的存储桶
  • 创建新存储桶
  • 已创建存储桶
  • 使用现有存储桶

返回值

🌐 Return value

一个承诺,解析为具有以下属性的对象:

🌐 A promise resolving to an object with the following properties:

bucketName

找到或创建的存储桶的名称。

🌐 The name of your bucket that was found or created.

alreadyExisted

一个布尔值,指示桶是已存在还是新创建的。

🌐 A boolean indicating whether the bucket already existed or was newly created.

另请参阅

🌐 See also