S3::Client::GetPresignedUrl does not support object keys with a version
- Lingua principale
- C++
- Stelle
- 2.2k
- Fork
- 1.2k
- Merge medio
- 4g 11h
- PR unite (30g)
- 13
Descrizione
### Describe the bug
We are not able to generate a presigned url for an S3 object with a version. The "key" parameter is url encoded by S3::Client and we are not able to specify the version.
This is what the calling code looks like
```
auto bucket = "myfiles";
auto filePath = "file.txt";
auto version = "a2dff23f-ccd5-4177-9798-56756def7f92";
auto key = filePath + "?versionId=" + version;
return m_awsSdkClient->GeneratePresignedUrl(
bucket, key, Aws::Http::HttpMethod::HTTP_GET);
```
### Expected Behavior
I would expect the generated url to be something like:
```
https:///myfiles/file.txt?versionId=4ef8f967-bb09-4307-a025-6ca5fa36d6d0&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DJPY5NIRF1B3CKNJHP62%2F20230605%2Fdev-14%2Fs3%2Faws4_request&X-Amz-Date=20230605T154734Z&X-Amz-Expires=604800&X-Amz-Security-Token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJESlBZNU5JUkYxQjNDS05KSFA2MiIsImF1dGhCYWNrZW5kIjoiSUFNIiwiYnBpIjoiYnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3IiwiZXhwIjoxNjg3MTg5NjU0LCJwYXJlbnQiOiJjdXN0b206YnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3Iiwicm9sZUFybiI6ImFybjptaW5pbzppYW06Ojpyb2xlL2lkbXAtamFudXMiLCJzdWIiOiJjdXN0b206YnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3In0.QrJsCiQc5SnUduqmtVnuteZWeGYvPeIigoH1zEn45pPTLoMQhGeBnYohe2u5q3Rnbb2HHIirbj9PhLwPXpb4Rg&X-Amz-SignedHeaders=host&X-Amz-Signature=1fa1d72e8e5da6e507c0a4008d9b66e061d0495c61d79c0405753d74a77eb393
```
### Current Behavior
The generated url is actually
```
https:///myfiles/file.txt%253FversionId=4ef8f967-bb09-4307-a025-6ca5fa36d6d0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DJPY5NIRF1B3CKNJHP62%2F20230605%2Fdev-14%2Fs3%2Faws4_request&X-Amz-Date=20230605T154734Z&X-Amz-Expires=604800&X-Amz-Security-Token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJESlBZNU5JUkYxQjNDS05KSFA2MiIsImF1dGhCYWNrZW5kIjoiSUFNIiwiYnBpIjoiYnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3IiwiZXhwIjoxNjg3MTg5NjU0LCJwYXJlbnQiOiJjdXN0b206YnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3Iiwicm9sZUFybiI6ImFybjptaW5pbzppYW06Ojpyb2xlL2lkbXAtamFudXMiLCJzdWIiOiJjdXN0b206YnBpOnN0YXRpYzpkc21kbWRmaWxlc3J3In0.QrJsCiQc5SnUduqmtVnuteZWeGYvPeIigoH1zEn45pPTLoMQhGeBnYohe2u5q3Rnbb2HHIirbj9PhLwPXpb4Rg&X-Amz-SignedHeaders=host&X-Amz-Signature=1fa1d72e8e5da6e507c0a4008d9b66e061d0495c61d79c0405753d74a77eb393
```
the `key` passed to the function is url encoded and therefore, we are not able to specify a "versionId" query parameter.
### Reproduction Steps
See the code sample above.
### Possible Solution
Allow `key` to include query parameters. I think this bug was a regression in [this commit](https://github.com/aws/aws-sdk-cpp/commit/da81fd5ac36c3af4a6637ee0c7f79386bf687cff#diff-ba2c23ee3e700440446a2911080ed16816a3a7acdc0ff37ce685cefb44fba69d)
it was already working before according to [this comment](https://github.com/aws/aws-sdk-cpp/issues/1068#issuecomment-463561621)
### Additional Information/Context
_No response_
### AWS CPP SDK version used
1.10.38
### Compiler and Version used
gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
### Operating System and version
Linux 81148edc27b5 3.10.0-1160.88.1.el7.x86_64
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da S3::Client::GeneratePresignedUrl e confronta il suo comportamento di codifica dell’URL con quello del commit di regressione collegato nell’issue e del commento precedente dell’issue. Usa la riproduzione fornita con un parametro di query versionId, quindi verifica che l’URL generato mantenga versionId come parametro di query invece di codificarlo nella chiave dell’oggetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, cpp
- Ambito
- api, cloud
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100