MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / transferFromS3

Function transferFromS3

storagetransfer/aws-request.js:61–99  ·  view source on GitHub ↗

* Creates a one-time transfer job from Amazon S3 to Google Cloud Storage.

()

Source from the content-addressed store, hash-verified

59 * Creates a one-time transfer job from Amazon S3 to Google Cloud Storage.
60 */
61 async function transferFromS3() {
62 // Setting the start date and the end date as the same time creates a
63 // one-time transfer
64 const now = new Date();
65 const oneTimeSchedule = {
66 day: now.getDate(),
67 month: now.getMonth() + 1,
68 year: now.getFullYear(),
69 };
70
71 // Runs the request and creates the job
72 const [transferJob] = await client.createTransferJob({
73 transferJob: {
74 projectId,
75 description,
76 status: 'ENABLED',
77 schedule: {
78 scheduleStartDate: oneTimeSchedule,
79 scheduleEndDate: oneTimeSchedule,
80 },
81 transferSpec: {
82 awsS3DataSource: {
83 bucketName: awsSourceBucket,
84 awsAccessKey: {
85 accessKeyId: awsAccessKeyId,
86 secretAccessKey: awsSecretAccessKey,
87 },
88 },
89 gcsDataSink: {
90 bucketName: gcsSinkBucket,
91 },
92 },
93 },
94 });
95
96 console.log(
97 `Created and ran a transfer job from '${awsSourceBucket}' to '${gcsSinkBucket}' with name ${transferJob.name}`
98 );
99 }
100
101 transferFromS3();
102 // [END storagetransfer_transfer_from_aws]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected