-
Notifications
You must be signed in to change notification settings - Fork 76
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 and url encoding #121
Comments
Can you reproduce this without scala? |
With a single file names 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())));
}
}
|
Do you have a pom.xml or build.gradle for this? |
I have sbt: |
the only thing needed is the gcloud storage dependency |
@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 you can check list of Also look at the below links which replacse the |
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. |
I thinks this is a duplicate of #57 Workaround to add this dependency:
|
Correct. Spaces should be encoded as %20 instead of a plus sign. |
The bug is in |
I built google-http-client 1.34.2-SNAPSHOT, the problem with spaces is gone! |
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> |
@soujiro32167 could you try using the latest release: Thank you for your patience folks. |
Verified the latest version has resolved the issue (GoogleCloudPlatform/java-docs-samples#2064). Closing issue, please reopen if the issue persists. |
@frankyn thanks! I'll try it out |
Environment details
General, Core, and Other are also allowed as types
Steps to reproduce
1+1 2
tomy-bucket
my-bucket
Code example
storage.list(bucket).iterateAll().asScala.foreach(blob => blob.downloadTo(blob.getName()))
Stack trace
External references such as API reference guides used
Any additional information below
If I try to encode the blob name using
blob.toBuilder.setBlodId(...).build
, I see double encoding:1%2B1%202 => 1%252B1%25202
Also, using
blob.signUrl
produces a valid url that allows downloadThe text was updated successfully, but these errors were encountered: