GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Check if Bucket.exists()? · Issue #1133 · googleapis/google-cloud-java

Check if Bucket.exists()? #1133

New issue
Copy link
New issue
Copy link
Closed
Closed
Check if Bucket.exists()?#1133
Copy link
Assignees
raintears

Description

@raintears
raintears
opened on Jul 29, 2016
Issue body actions

Hi,

I still can't understand how can I use bucket.exists from the documentation. I don't even know how to instantiate a new bucket. This is what I did.

Bucket bucket = new Bucket("bucketname");
return bucket.exists();

Apparently I can't instantiate a new bucket like this, so how then can I use bucket.exists()?

Activity

  1. mziccard commented on Aug 8, 2016

    @mziccard
    mziccard
    on Aug 8, 2016
    Contributor
    More actions

    Hi @raintears,

    Bucket is a class that contains all information of a bucket, in contrast with BucketInfo, the Bucket class also exposes methods to update and delete the bucket. Bucket objects cannot be created directly but are returned by Storage methods like create and get.

    To check for the existence of a bucket if you do not have an instance of Bucket you can do the following:

    return storage.get("bucketname", Storage.BucketGetOption.fields()) != null;

    storage.get will return a Bucket object or null if not found. Storage.BucketGetOption.fields() tells the service to return only the bucket name (we don't need to transfer all bucket's fields to check for existence).

    Reacted by raintears, Gerry Surya, Kartik, Kevin Kibue Kariuki, Jay Sardhara, Carlos Pupo Ortiz, Dan McCabe, mazegen and Shubham Jain
  2. raintears commented on Aug 10, 2016

    @raintears
    raintears
    on Aug 10, 2016
    Author
    More actions

    Thanks @mziccard

    This explanation is more straightforward!

  3. raintears
    closed this as completedon Aug 10, 2016
  4. kaus22 commented on Jul 24, 2018

    @kaus22
    kaus22
    on Jul 24, 2018
    More actions

    @mziccard which package did you get your Storage class from?
    I'm using com.google.api.services.storage.Storage and BucketGetOptions.fields() is not getting resolved.

    Reacted by Pascal, Keith and Mohamed Benothmane
  5. JustinBeckwith
    assigned
    raintears
    on Feb 1, 2021
  6. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore: Update blunderbuss with issues/pr reviewer (#1133)

    3ecb2a5
  7. chingor13
    added a commit that references this issue on Jan 6, 2026

    deps: update dependency com.google.cloud:google-cloud-logging to v3.1…

    940c3bb
  8. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore: Update blunderbuss with issues/pr reviewer (googleapis#1133)

    66296f4
  9. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    a488320

    chore(main): release 2.9.6 (googleapis#1134)

    e39a310
  10. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(main): release 0.126.9-SNAPSHOT (#1133)

    5df902c
  11. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(main): release 0.126.9-SNAPSHOT (#1133)

    e24578b
  12. meltsufin
    added 4 commits that reference this issue on Apr 29, 2026

    feat: add BigQuery configuration for subscriptions (#1133)

    6f271db

    chore(main): release 1.119.0 (#1144)

    e15ef6c

    feat: add BigQuery configuration for subscriptions (#1133)

    2a65197

    chore(main): release 1.119.0 (#1144)

    67440b3
  13. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore(java): update variable name to api_shortname in README template (…

    7338a56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @raintears
    raintears

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.