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

Setting userProject from NIO FileSystemProvider #3475

Closed
ryan-williams opened this issue Jul 17, 2018 · 4 comments · Fixed by #3504
Closed

Setting userProject from NIO FileSystemProvider #3475

ryan-williams opened this issue Jul 17, 2018 · 4 comments · Fixed by #3504
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: question Request for information or clarification. Not an issue.

Comments

@ryan-williams
Copy link

I'm happy to see that requester-pays support was just added!

afaict, I can't set the userProject in a CloudStorageFileSystemProvider that gets instantiated via the Java NIO FileSystemProvider machinery, which uses Class.newInstance() to invoke the nullary constructor:

import java.net.URI;
import java.nio.file.Paths;
import java.nio.file.Files;
Files.newDirectoryStream(Paths.get(new URI("gs://<bucket>")))

throws:

com.google.cloud.storage.StorageException: Bucket is requester pays bucket but no user project provided.
  at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:220)
  at com.google.cloud.storage.spi.v1.HttpStorageRpc.list(HttpStorageRpc.java:347)
  at com.google.cloud.storage.StorageImpl$8.call(StorageImpl.java:299)
  …

Is there a way to set the user-project, other than as a ctor param?

@yihanzhen yihanzhen added type: question Request for information or clarification. Not an issue. api: storage Issues related to the Cloud Storage API. labels Jul 17, 2018
@yihanzhen
Copy link
Contributor

You could set the userProject in CloudStorageConfiguration as is in the tests. Please let us know if that's not what you want.

@ryan-williams
Copy link
Author

Thanks for that pointer @hzyi-google; that helped, but I still needed #3504.

CloudStorageFileSystemProvider checks its instance var userProject to determine whether to set that parameter when calling storage.get, but that was never being set from [the config passed to setDefaultCloudStorageConfiguration].

@yihanzhen
Copy link
Contributor

Thanks for the clarification and contribution! I added a few comments in the pull request, can you take a look please?

@ryan-williams
Copy link
Author

jfyi: I published a fork of the google-cloud-nio module with this merged at org.lasersonlab:google-cloud-nio:0.55.2-alpha; I think the PR is awaiting review, but no rush on my end 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants