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

Calling bucket.file.exists always returns false #1556

Closed
VanPaitin opened this issue Apr 11, 2024 · 5 comments
Closed

Calling bucket.file.exists always returns false #1556

VanPaitin opened this issue Apr 11, 2024 · 5 comments

Comments

@VanPaitin
Copy link

import { Storage } from '@google-cloud/storage';

const storage = new Storage();
const apiBucket = storage.bucket('api-video-song-renderer-bucket-test');
apiBucket.file(`shakaraSTART`).save("Hello world", {
  public: true
});

Running the code above correctly creates a file in the bucket. When I check the logs, I see it makes a call to
POST /upload/storage/v1/b/api-video-song-renderer-bucket-test/o?name=shakaraSTART&uploadType=resumable&predefinedAcl=publicRead.

However, when I try to check with:

apiBucket.file('shakaraSTART').exists().then(exists => {
  expect(exists).toBe(true);
});

I am always getting a false value meaning the file doesn't exist when it infact exists. I checked the logs and it was making calls to
GET /b/api-video-song-renderer-bucket-test/o/shakaraSTART

Observe that it doesn't prepend the endpoint with /storage/v1. This is probably why I am getting a 404 error.

  1. Is there a work around for this?
  2. Is this a bug and will it be fixed?
  3. What may I be getting wrong?
@fsouza
Copy link
Owner

fsouza commented Apr 15, 2024

How did you configure the node client to talk to fake-gcs-server?

@VanPaitin
Copy link
Author

Thanks @fsouza for your reply. I am configuring the client simply by setting the env variable: STORAGE_EMULATOR_HOST='http://localhost:4443'

@VanPaitin
Copy link
Author

@fsouza, should I expect a solution?

@fsouza
Copy link
Owner

fsouza commented Apr 30, 2024

Can you provide exact steps for reproducing the issue?

I just tried to reproduce with the example in the repo and couldn't: #1585

If the client is not sending the correct request to the server, I assume the client is misconfigured.

@fsouza
Copy link
Owner

fsouza commented May 2, 2024

Merged #1585, see that for an example on how to setup the Node client in a way where that method works.

@fsouza fsouza closed this as completed May 2, 2024
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

2 participants