Skip to content

feat(file-storage): add methods to check whether bucket exists #89

Open
@getlarge

Description

@getlarge

Method for GC Storage:

// ...
  async bucketExists(): Promise<boolean> {
    const { storage, bucket } = this.config;
    try {
      const [exists] = await storage.bucket(bucket).exists();
      return exists;
    } catch (e) {
      return false;
    }
  }
  //... 
  • Method for AWS S3:
  async bucketExists(): Promise<boolean> {
    const { s3, bucket: Bucket } = this.config;
    try {
      await s3.headBucket({ Bucket });
      return true;
    } catch (e) {
      return false;
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions