Comments (15)
Can you reproduce this without scala?
from java-storage.
With a single file names 1 1
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.nio.file.Path;
public class Yava {
public static void main(String[] args) {
Storage storage = StorageOptions.getDefaultInstance().getService();
storage.list("eli-test").iterateAll().forEach(blob -> blob.downloadTo(Path.of("target", blob.getName())));
}
}
Exception in thread "main" com.google.cloud.RetryHelper$RetryHelperException: com.google.cloud.storage.StorageException: 404 Not Found
No such object: eli-test/1+1
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:54)
at com.google.cloud.storage.Blob.downloadTo(Blob.java:233)
at com.google.cloud.storage.Blob.downloadTo(Blob.java:217)
at com.google.cloud.storage.Blob.downloadTo(Blob.java:260)
at Yava.lambda$main$0(Yava.java:9)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at Yava.main(Yava.java:9)
Caused by: com.google.cloud.storage.StorageException: 404 Not Found
No such object: eli-test/1+1
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:229)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.read(HttpStorageRpc.java:675)
at com.google.cloud.storage.Blob$2.run(Blob.java:238)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
... 6 more
Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found
No such object: eli-test/1+1
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
at com.google.api.client.googleapis.media.MediaHttpDownloader.executeCurrentRequest(MediaHttpDownloader.java:255)
at com.google.api.client.googleapis.media.MediaHttpDownloader.download(MediaHttpDownloader.java:185)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeMediaAndDownloadTo(AbstractGoogleClientRequest.java:685)
at com.google.api.services.storage.Storage$Objects$Get.executeMediaAndDownloadTo(Storage.java:6996)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.read(HttpStorageRpc.java:671)
... 11 more
from java-storage.
Do you have a pom.xml or build.gradle for this?
from java-storage.
I have sbt: "com.google.cloud" % "google-cloud-storage" % "1.103.1"
from java-storage.
the only thing needed is the gcloud storage dependency
from java-storage.
@soujiro32167 Thanks for pointing out this bug, but it's related to google-http-java-client.
FYI, A string of characters that do not need to be encoded when used in URI
query strings, as
specified in RFC 3986
. Note that some of these characters do need to be escaped
when used in
other parts of the URI
and space
is one of them which needs to be escape.
you can check list of rules
for an encoding
a string which is parts of the URI
.
Also look at the below links which replacse the space
with {'+'}
from java-storage.
The problem is not that the space is not being encoded. It's that it's being encoded incorrectly as a plus sign. This is wrong. The plus sign is the plus sign. It is not a space and does not represent one in URLs. This is a common confusion between URL encoding and application-x-www-formurl-encoding. The latter only applies in HTML forms.
This is complicated because there's a lot of broken code out there that does not follow the spec. To make matters worse, some of the GCS code is trying to be bug-for-bug compatible with other non-Google code.
from java-storage.
I thinks this is a duplicate of #57
it's still reproducible with google-http-client 1.34.1
Workaround to add this dependency:
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.33.0</version>
</dependency>
from java-storage.
The problem is not that the space is not being encoded. It's that it's being encoded incorrectly as a plus sign. This is wrong. The plus sign is the plus sign. It is not a space and does not represent one in URLs. This is a common confusion between URL encoding and application-x-www-formurl-encoding. The latter only applies in HTML forms.
This is complicated because there's a lot of broken code out there that does not follow the spec. To make matters worse, some of the GCS code is trying to be bug-for-bug compatible with other non-Google code.
Correct. Spaces should be encoded as %20 instead of a plus sign.
from java-storage.
The bug is in com.google.api.client.http.UriTemplate#expand
or something it calls. This is where the + sign is incorrectly introduced.
from java-storage.
I built google-http-client 1.34.2-SNAPSHOT, the problem with spaces is gone!
from java-storage.
FYI if you import com.google.cloud:libraries-bom:4.1.0 or later the bug is fixed. We still need to release a version of the google-cloud-storage artifact that updates its dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>4.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
from java-storage.
@soujiro32167 could you try using the latest release:
https://search.maven.org/artifact/com.google.cloud/google-cloud-storage-parent/1.104.0/pom
Thank you for your patience folks.
from java-storage.
Verified the latest version has resolved the issue (GoogleCloudPlatform/java-docs-samples#2064). Closing issue, please reopen if the issue persists.
from java-storage.
@frankyn thanks! I'll try it out
from java-storage.
Related Issues (20)
- Add Support for includeFolders option in ListObjects HOT 3
- Fix retry logic on SSL Connection Reset errors and Error writing request body to server HOT 1
- storage: memory leak while writing to GCS bucket HOT 6
- Uploading files to GCS via WriteChannel cause the memory to increase - memory not released HOT 3
- Use opentelemetry for tracing google-cloud-storage client calls
- Storage.writer(...) breaks the idea of 'generation' HOT 2
- Support for Storage Control Quickstart
- Issue with GCS matchGlob method HOT 3
- Jqwik Usage Survey HOT 2
- createFrom(BlobInfo blobInfo, Path path, int bufferSize, BlobWriteOption... options) ignores bufferSize HOT 2
- allow cancelling a resumable upload HOT 1
- allow specifying the content length for resumable uploads HOT 2
- storage: PCU hangs HOT 9
- Checksum verification when uploading file to cloud storage not working - version 2.36.1 HOT 2
- transfer manager PCUs should allowing specifying a key prefix for intermediate objects
- GCS : Spring Boot service gets blocked with virtual thread and library version >= 2.25.0 during file upload HOT 6
- Allow to create presigned URLs using HMAC keys HOT 1
- Add HNS folders samples
- Support StripPrefix on upload for TransferManager
- Warning: a recent release failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-storage.