let client = Client::default();
let mut object = client.object().read("mybucket", "myfile").await?;
object.name = "mybetterfile".to_string();
client.object().update(&object).await?;
However, this uses the name of the given object to know what to apply the changes to. So when you try to rename a file, Google will tell you that it wasn't found (since it doesn't exist yet).
At the very least, this example should be removed and the docs updated. (update, as well as compose, seem to have the same entry as read in the docs). We can perform the operation with a rewrite/copy to the same bucket, but that's less than ideal, especially because rewrite has a dbg left in.
Doesn't look like you can rename objects through the /b/{bucket}/o/{object} endpoint (even if the original path is specified), so the linked PR just updates the docs explaining this limitation.
The module docs include this example:
However, this uses the name of the given object to know what to apply the changes to. So when you try to rename a file, Google will tell you that it wasn't found (since it doesn't exist yet).
At the very least, this example should be removed and the docs updated. (
update
, as well ascompose
, seem to have the same entry asread
in the docs). We can perform the operation with arewrite
/copy
to the same bucket, but that's less than ideal, especially because rewrite has adbg
left in.