Skip to main content

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

ParameterCLI optionTypeRequiredDescription
SourcePath--snameStringPath (name) in the source bucket
DestinationBucket--sbucketStringSource bucket name
DestinationPath--nameStringPath (name) in the destination bucket
SourceBucket--bucketStringDestination bucket name
BasicData--basicStructure of KeyAndValueBasic request data. See GetBasicDataStructure
Headers--headersMap Of KeyAndValueAdditional request headers, if necessary

Returns: Structure of KeyAndValue - serialized JSON response from storage


tip

Method at AWS documentation: CopyObject


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);
    # 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'}"
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"
}
}