← All procedures

s3.copy

Copy an object inside S3 (it replaces the destination, unless overwrite is false)

CLI
Package
@procedures/s3 · README
Path
["s3","copy"]
CLI
mark s3 copy --sourceKey <string> --bucket <string> --key <string>
As data
{"$proc":["s3","copy"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/s3/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["s3","copy"], { sourceKey: "<sourceKey>", bucket: "<bucket>", key: "<key>" });
console.log(JSON.stringify(result));

From the command line

$ mark s3 copy --sourceKey <string> --bucket <string> --key <string>

As data, in a program

{
  "$proc": ["s3", "copy"],
  "input": {
    "sourceKey": "<sourceKey>",
    "bucket": "<bucket>",
    "key": "<key>"
  }
}

Input

FieldTypeRequiredDefaultDescription
sourceBucketstringnoThe bucket of the source (default: the bucket of the destination)
sourceKeystringyesThe key of the source
sourceVersionIdstringnoA version of the source (default: the current version)
bucketstringyesThe bucket of the destination
keystringyesThe key of the destination
overwritebooleannoFalse: S3 refuses the copy when the destination key exists. The default is true.
contentTypestringnoA new content type: the copy then replaces the metadata of the source
metadataobjectnoNew user metadata: the copy then replaces the metadata of the source

Output

FieldTypeRequiredDefaultDescription
etagstringyesThe ETag of the copy, without quotes
lastModifiedstringnoThe time of the last change of the copy (ISO 8601)
versionIdstringnoThe version id of the copy, when the bucket has versioning
sourceVersionIdstringnoThe version id of the source, when its bucket has versioning
locationstringyesThe S3 URI of the copy (s3://bucket/key)
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "sourceBucket": {
        "description": "The bucket of the source (default: the bucket of the destination)",
        "type": "string",
        "minLength": 1
      },
      "sourceKey": {
        "type": "string",
        "minLength": 1,
        "description": "The key of the source"
      },
      "sourceVersionId": {
        "description": "A version of the source (default: the current version)",
        "type": "string"
      },
      "bucket": {
        "type": "string",
        "minLength": 1,
        "description": "The bucket of the destination"
      },
      "key": {
        "type": "string",
        "minLength": 1,
        "description": "The key of the destination"
      },
      "overwrite": {
        "description": "False: S3 refuses the copy when the destination key exists. The default is true.",
        "type": "boolean"
      },
      "contentType": {
        "description": "A new content type: the copy then replaces the metadata of the source",
        "type": "string"
      },
      "metadata": {
        "description": "New user metadata: the copy then replaces the metadata of the source",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "string"
        }
      }
    },
    "required": [
      "sourceKey",
      "bucket",
      "key"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "etag": {
        "type": "string",
        "description": "The ETag of the copy, without quotes"
      },
      "lastModified": {
        "description": "The time of the last change of the copy (ISO 8601)",
        "type": "string"
      },
      "versionId": {
        "description": "The version id of the copy, when the bucket has versioning",
        "type": "string"
      },
      "sourceVersionId": {
        "description": "The version id of the source, when its bucket has versioning",
        "type": "string"
      },
      "location": {
        "type": "string",
        "description": "The S3 URI of the copy (s3://bucket/key)"
      }
    },
    "required": [
      "etag",
      "location"
    ],
    "additionalProperties": {}
  }
}