ThouCheese / cloud-storage-rs

A crate for uploading files to Google cloud storage, and for generating download urls.
MIT License
123 stars 88 forks source link

Moving/renaming object with `update` doesn't work #109

Closed junbl closed 2 years ago

junbl commented 2 years ago

The module docs include this example:

Renaming/moving a file

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.

junbl commented 2 years ago

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.