pub async fn rewrite(&self, destination_bucket: &str, path: &str) -> crate::Result<Self> {
        use reqwest::header::CONTENT_LENGTH;

        let url = format!(
            "{base}/b/{sBucket}/o/{sObject}/rewriteTo/b/{dBucket}/o/{dObject}",
            base = crate::BASE_URL,
            sBucket = percent_encode(&self.bucket),
            sObject = percent_encode(&self.name),
            dBucket = percent_encode(destination_bucket),
            dObject = percent_encode(path),
        );
        let mut headers = crate::get_headers().await?;
        headers.insert(CONTENT_LENGTH, "0".parse()?);
        let result: GoogleResponse<RewriteResponse> = crate::CLIENT
            .post(&url)
            .headers(headers)
            .send()
            .await?
            .json()
            .await?;
        match result {
            GoogleResponse::Success(s) => Ok(s.resource),
            GoogleResponse::Error(e) => Err(e.into()),
        }
    }
/// Moves a file from the current location to the target bucket and path.
///
/// ## Limitations
/// This function does not yet support rewriting objects to another
/// * Geographical Location,
/// * Encryption,
/// * Storage class.
/// These limitations mean that for now, the rewrite and the copy methods do the same thing.
/// ### Example
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use cloud_storage::object::Object;
///
/// let obj1 = Object::read("my_bucket", "file1").await?;
/// let obj2 = obj1.rewrite("my_other_bucket", "file2").await?;
/// // obj2 is now a copy of obj1.
/// # Ok(())
/// # }
/// ```
Moves a file from the current location to the target bucket and path.
Moves a file from the current location to the target bucket and path .
pub async fn rewrite(&self, destination_bucket: &str, path: &str) -> crate::Result<Self> {
        use reqwest::header::CONTENT_LENGTH;
        let url = format!(
            "{base}/b/{sBucket}/o/{sObject}/rewriteTo/b/{dBucket}/o/{dObject}",
            base = crate::BASE_URL,
            sBucket = percent_encode(&self.bucket),
            sObject = percent_encode(&self.name),
            dBucket = percent_encode(destination_bucket),
            dObject = percent_encode(path),
        );
        let mut headers = crate::get_headers().await?;
        headers.insert(CONTENT_LENGTH, "0".parse()?);
        let result: GoogleResponse<RewriteResponse> = crate::CLIENT
            .post(&url)
            .headers(headers)
            .send()
            .await?
            .json()
            .await?;
        match result {
            GoogleResponse::Success(s) => Ok(s.resource),
            GoogleResponse::Error(e) => Err(e.into()),
        }
    }
pub async fn rewrite ( & self , destination_bucket : & str , path : & str ) -> crate :: Result < Self > { use reqwest :: header :: CONTENT_LENGTH ; let url = format ! ( " " base crate BASE_URL sBucket percent_encode ( self bucket ) sObject percent_encode ( self name ) dBucket percent_encode ( destination_bucket ) dObject percent_encode ( path ) ) ; let mut headers = crate :: get_headers ( ) . await ? ; headers . insert ( CONTENT_LENGTH , " " . parse ( ) ? ) ; let result : GoogleResponse < RewriteResponse > = crate :: CLIENT . post ( & url ) . headers ( headers ) . send ( ) . await ? . json ( ) . await ? ; match result { GoogleResponse :: Success ( s ) => Ok ( s . resource ) , GoogleResponse :: Error ( e ) => Err ( e . into ( ) ) , } }
Moves a file from the current location to the target bucket and path.
Moves a file from the current location to the target bucket and path .
&self
destination_bucket
&str
path
&str
limitations
This function does not yet support rewriting objects to another
Geographical Location,
Encryption,
Storage class.
These limitations mean that for now, the rewrite and the copy methods do the same thing.
This function does not yet support rewriting objects to another Geographical Location Encryption Storage class . These limitations mean that for now the rewrite and the copy methods do the same thing .
example
None
#[tokio::main]
None
async fn main() -> result<(), box<dyn std::error::error>> {
use cloud_storage::object::Object.

let obj1 = Object::read("my_bucket", "file1").await?;
let obj2 = obj1.rewrite("my_other_bucket", "file2").await?;
obj2 is now a copy of obj1.
use cloud_storage :: object :: Object . let obj1 = Object :: read ( " my_bucket " " file1 " ) . await? ; let obj2 = obj1 . rewrite ( " my_other_bucket " " file2 " ) . await? ; obj2 is now a copy of obj1 .
ok(())
None
}
None