Commit ec470a2
fix(bucket): Move blob fails when the new blob name contains characters that need to be url encoded (#1605)
fix(bucket): url encode new_name parameter in move_blob()
The move_blob() method was not URL encoding the new_name parameter
before passing it to the API call, unlike how the blob encodes its own
path. This caused failures when moving blobs to paths with special
characters.
Added URL encoding for new_name to match the blob path encoding, as
both names must fit in the API URL format:
"{blob_path}/moveTo/o/{new_name}"
Here's an example of what fails:
```python
from google.cloud import storage
gcs = storage.Client()
bucket = gcs.bucket("")
blob = bucket.get_blob("test/blob.csv")
bucket.move_blob(
blob,
new_name="test/blob2.csv"
)
```
Fixes #1523
---------
Co-authored-by: Chandra Shekhar Sirimala <[email protected]>1 parent 7d17922 commit ec470a2
2 files changed
+37
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
2360 | 2361 | | |
2361 | 2362 | | |
2362 | 2363 | | |
2363 | | - | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
2364 | 2368 | | |
2365 | 2369 | | |
2366 | 2370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
2320 | 2321 | | |
2321 | 2322 | | |
2322 | 2323 | | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
2323 | 2355 | | |
2324 | 2356 | | |
2325 | 2357 | | |
| |||
0 commit comments