Skip to content

Commit

Permalink
Fix bugs in wrapper around gcloud rewrite
Browse files Browse the repository at this point in the history
Two things were working incorrectly:
- The objects were not using percent encoding, resulting in an
incorrect uri, and
- the response was incorrectly parsed due to an incorrect decoder
  • Loading branch information
benbellick committed Dec 18, 2024
1 parent d3995c0 commit fc3ed55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/storage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type rewrite_object_response = {
kind : string;
total_bytes_rewritten : string; [@key "totalBytesRewritten"]
object_size : string; [@key "objectSize"]
done_ : bool;
done_ : bool; [@key "done"]
rewrite_token : string option; [@key "rewriteToken"] [@default None]
resource : Yojson.Safe.t option; [@default None]
}
Expand All @@ -111,6 +111,8 @@ let rewrite_object source_bucket source_object destination_bucket
Lwt.catch
(fun () ->
let uri =
let source_object = Uri.pct_encode source_object in
let destination_object = Uri.pct_encode destination_object in
Uri.make () ~scheme:"https" ~host:"storage.googleapis.com"
~path:
(Printf.sprintf "storage/v1/b/%s/o/%s/rewriteTo/b/%s/o/%s"
Expand Down

0 comments on commit fc3ed55

Please sign in to comment.