aws / aws/aws-sdk-java-v2

S3Utilities.parseUri(): support unencoded URI

未关闭
#3,955 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
feature-request p2
主要语言
Java
星标
2.6k
派生
1k
平均合并
2 天 9 小时
30 天内合并 PR
51

描述

### Describe the bug

I currently have an S3 object with the S3 URI `s3://test-bucket/test file with spaces`. When I attempt to create an `S3Uri` object with the `parseUri()` method ([code](https://github.com/aws/aws-sdk-java-v2/blob/b0f57372dbe6be1fb2a6a54b05ad1f1a7e1e7700/services/s3/src/main/java/software/amazon/awssdk/services/s3/S3Utilities.java#L292)), I receive the following exception:

```kotlin
// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))

// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
at java.net.URI$Parser.fail (:-1)
at java.net.URI$Parser.checkChars (:-1)
at java.net.URI$Parser.parseHierarchical (:-1)
```

This is due to the URI constructor, specifically because it does not allow input strings to have spaces in them. However, valid S3 URIs can contain spaces in them.

### Expected Behavior

```kotlin
// Code
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
println(s3Uri) // S3Uri(uri=s3://test-bucket/test file with spaces, bucket=test-bucket, key=test file with spaces, isPathStyle=false, queryParams={})
```

### Current Behavior

```kotlin
// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))

// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
at java.net.URI$Parser.fail (:-1)
at java.net.URI$Parser.checkChars (:-1)
at java.net.URI$Parser.parseHierarchical (:-1)
```

### Reproduction Steps

```kotlin
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS Java SDK version used

2.0

### JDK version used

8

### Operating System and version

macOS 12.6.5

贡献指南

打开贡献指南

调研方向

从 services/s3/src/main/java/software/amazon/awssdk/services/s3/S3Utilities.java 中的 S3Utilities.parseUri() 开始,然后跟踪所提供的 URI 如何被读取为 bucket 和 key 组件。确认现有的 parseUri() 行为和测试,并在能够解析包含未编码空格的 S3 URI、同时保持现有 URI 处理不变时,认为该 issue 已完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, java
领域
cloud
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。