MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / copy

Function copy

javascriptv3/example_code/s3/scenarios/basic.js:104–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 return;
103 }
104 const copy = async () => {
105 try {
106 const sourceBucket = await prompter.input({
107 message: "Enter source bucket name:",
108 });
109 const sourceKey = await prompter.input({
110 message: "Enter source key:",
111 });
112 const destinationKey = await prompter.input({
113 message: "Enter destination key:",
114 });
115
116 const command = new CopyObjectCommand({
117 Bucket: destinationBucket,
118 CopySource: `${sourceBucket}/${sourceKey}`,
119 Key: destinationKey,
120 });
121 await s3Client.send(command);
122 await copyFileFromBucket({ destinationBucket });
123 } catch (err) {
124 console.error("Copy error.");
125 console.error(err);
126 const retryAnswer = await prompter.confirm({ message: "Try again?" });
127 if (retryAnswer) {
128 await copy();
129 }
130 }
131 };
132 await copy();
133};
134// snippet-end:[javascript.v3.s3.scenarios.basic.CopyObject]

Callers 5

copyFileFromBucketFunction · 0.85
ReadMethod · 0.85
SetupDataAndStubsMethod · 0.85
ReadMethod · 0.85
SetupDataAndStubsMethod · 0.85

Calls 4

copyFileFromBucketFunction · 0.85
confirmMethod · 0.80
inputMethod · 0.45
sendMethod · 0.45

Tested by 4

ReadMethod · 0.68
SetupDataAndStubsMethod · 0.68
ReadMethod · 0.68
SetupDataAndStubsMethod · 0.68