---
sidebar_position: 10
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Copy object
 Copies an object from one location to another



`Function CopyObject(Val SourcePath, Val DestinationBucket, Val DestinationPath, Val SourceBucket, Val BasicData, Val Headers = Undefined) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | SourcePath | --sname | String | ✔ | Path (name) in the source bucket |
  | DestinationBucket | --sbucket | String | ✔ | Source bucket name |
  | DestinationPath | --name | String | ✔ | Path (name) in the destination bucket |
  | SourceBucket | --bucket | String | ✔ | Destination bucket name |
  | BasicData | --basic | Structure Of KeyAndValue | ✔ | Basic request data. See GetBasicDataStructure |
  | Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |

  
  Returns:  Structure Of KeyAndValue - serialized JSON response from storage

<br/>

:::tip
Method at AWS documentation: [CopyObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html)
:::
<br/>



```bsl title="1C:Enterprise/OneScript code example"
    URL       = "storage-155.s3hoster.by";
    AccessKey = "BRN5RKJE67...";
    SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
    Region    = "BTC";

    BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);

    SourcePath        = "picture.jpg";
    DestinationBucket = "opi-gpbucket3";

    DestinationPath = "new_picture.jpg";
    SourceBucket    = "opi-dirbucket3";

    Result = OPI_S3.CopyObject(SourcePath, DestinationBucket, DestinationPath, SourceBucket, BasicData);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint s3 CopyObject \
             --sname "picture.jpg" \
             --sbucket "opi-gpbucket3" \
             --name "new_picture.jpg" \
             --bucket "opi-dirbucket3" \
             --basic "{'URL':'storage-155.s3hoster.by','AccessKey':'***','SecretKey':'***','Region':'BTC','Service':'s3'}"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint s3 CopyObject ^
             --sname "picture.jpg" ^
             --sbucket "opi-gpbucket3" ^
             --name "new_picture.jpg" ^
             --bucket "opi-dirbucket3" ^
             --basic "{'URL':'storage-155.s3hoster.by','AccessKey':'***','SecretKey':'***','Region':'BTC','Service':'s3'}"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "status": 200,
 "response": {
  "CopyObjectResult": {
   "LastModified": "2024-11-22T10:12:24.105Z",
   "ETag": "\"9e0176f87f6565a22f78e0f9b39a4d78\""
  }
 },
 "headers": {
  "Accept-Ranges": "bytes",
  "Content-Length": "232",
  "Content-Type": "application/xml",
  "Date": "Fri, 22 Nov 2024 10:12:24 GMT",
  "Etag": "\"9e0176f87f6565a22f78e0f9b39a4d78\"",
  "Server": "MinIO",
  "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
  "Vary": "Origin,Accept-Encoding",
  "X-Amz-Id-2": "057275ee0636b36a8256f409a6ff665de46bfaa1f0d5faf2d1b4f312e55c34fa",
  "X-Amz-Request-Id": "180A42B32EB9D5A1",
  "X-Content-Type-Options": "nosniff",
  "X-Xss-Protection": "1; mode=block"
 }
}
```