Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
getlarge opened this issue Aug 7, 2024 · 0 comments
Open

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

getlarge opened this issue Aug 7, 2024 · 0 comments

Comments

@getlarge
Copy link
Owner

getlarge commented Aug 7, 2024

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;
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant