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

Storage.get(bucketname,filepath) returns null when filename has space (1.103.1,java8) #156

Closed
sudipidus opened this issue Mar 2, 2020 · 5 comments
Assignees
Labels
api: storage Issues related to the googleapis/java-storage API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@sudipidus
Copy link
Contributor

sudipidus commented Mar 2, 2020

Steps to reproduce

  1. create a file inside a bucket which has space in its name (eg: hotel booking.pdf)
  2. try to download the blob using storage.get(bucket,filepath)

Code example

log.info("Attempting to download file {} from bucket {}", filePath,bucketName);
    Blob blob = storage.get(bucketName, filePath);
    if (Objects.isNull(blob)) {
      log.error("file not present for {}", fileName);
      //            throw new FileNotFoundException("file not present for: {}", fileName);
    }

Stack trace

file not present for 'hotel booking.pdf'

External references such as API reference guides

  • ?

Any additional information below

Following these steps guarantees the quickest resolution possible.

Thanks!

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/java-storage API. label Mar 2, 2020
@athakor athakor self-assigned this Mar 2, 2020
@athakor
Copy link
Contributor

athakor commented Mar 2, 2020

@sudipbhandari126 could you try using the latest releases:
https://search.maven.org/artifact/com.google.cloud/google-cloud-storage-parent/1.104.0/pom OR https://search.maven.org/artifact/com.google.cloud/google-cloud-storage-parent/1.105.0/pom

Verified the latest version has resolved this issue below are the code sample and response.

Code sample

public class StorageTest {

  public static void main(String[] args) {
    try {
      Storage storage = StorageOptions.getDefaultInstance().getService();
      String bucketName = "ajit-test-bucket";
      String fileName = "file test.txt";
      Blob blob = storage.get(bucketName, fileName);
      if (Objects.isNull(blob)) {}
      System.out.println("Blob Response:" + blob);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

Output :

Blob Response:Blob{bucket=test-bucket, name=file test.txt, generation=1583146265562128, size=21, content-type=null, metadata=null}

@sudipidus
Copy link
Contributor Author

My build is failing for the latest version with the following errror:

Could not find androidx.annotation:annotation:1.1.0
....
Required by:
      project :core > com.google.api-client:google-api-client:1.30.8

@athakor
Copy link
Contributor

athakor commented Mar 2, 2020

@sudipbhandari126 please check the issue #148

@sudipidus
Copy link
Contributor Author

Great.
Thanks for the quick response.

couple questions:

  1. why an additional dependency wasn't bundled?
  2. why sudden change while upgrading version that we had to add new repository?

@athakor
Copy link
Contributor

athakor commented Mar 2, 2020

~cc:/ @elharo

@elharo elharo closed this as completed Mar 2, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
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 googleapis/java-storage API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants