﻿---
sidebar_position: 9
---

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 | &#x2714; | Path (name) in the source bucket |
  | DestinationBucket | --sbucket | String | &#x2714; | Source bucket name |
  | DestinationPath | --name | String | &#x2714; | Path (name) in the destination bucket |
  | SourceBucket | --bucket | String | &#x2714; | Destination bucket name |
  | BasicData | --basic | Structure of KeyAndValue | &#x2714; | Basic request data. See GetBasicDataStructure |
  | Headers | --headers | Map Of KeyAndValue | &#x2716; | 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>



