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

        let url = format!(
            "{base}/b/{sBucket}/o/{sObject}/copyTo/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<Self> = crate::CLIENT
            .post(&url)
            .headers(headers)
            .send()
            .await?
            .json()
            .await?;
        match result {
            GoogleResponse::Success(s) => Ok(s),
            GoogleResponse::Error(e) => Err(e.into()),
        }
    }
/// Copy this object to the target bucket and path
/// ### Example
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use cloud_storage::object::{Object, ComposeRequest};
///
/// let obj1 = Object::read("my_bucket", "file1").await?;
/// let obj2 = obj1.copy("my_other_bucket", "file2").await?;
/// // obj2 is now a copy of obj1.
/// # Ok(())
/// # }
/// ```
Copy this object to the target bucket and path
Copy this object to the target bucket and path
pub async fn copy(&self, destination_bucket: &str, path: &str) -> crate::Result<Self> {
        use reqwest::header::CONTENT_LENGTH;
        let url = format!(
            "{base}/b/{sBucket}/o/{sObject}/copyTo/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<Self> = crate::CLIENT
            .post(&url)
            .headers(headers)
            .send()
            .await?
            .json()
            .await?;
        match result {
            GoogleResponse::Success(s) => Ok(s),
            GoogleResponse::Error(e) => Err(e.into()),
        }
    }
pub async fn copy ( & 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 < Self > = crate :: CLIENT . post ( & url ) . headers ( headers ) . send ( ) . await ? . json ( ) . await ? ; match result { GoogleResponse :: Success ( s ) => Ok ( s ) , GoogleResponse :: Error ( e ) => Err ( e . into ( ) ) , } }
Copy this object to the target bucket and path
Copy this object to the target bucket and path
&self
destination_bucket
&str
path
&str
example
None
#[tokio::main]
None
async fn main() -> result<(), box<dyn std::error::error>> {
use cloud_storage::object::{Object, ComposeRequest}.

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