MCPcopy Create free account
hub / github.com/ShipSecAI/studio / create

Function create

worker/src/destinations/adapters/s3.ts:49–106  ·  view source on GitHub ↗
(rawConfig)

Source from the content-addressed store, hash-verified

47 { id: 'publicUrl', label: 'Public URL prefix', type: 'text' },
48 ],
49 create(rawConfig) {
50 return {
51 async save(
52 input: DestinationSaveInput,
53 context: ExecutionContext,
54 ): Promise<DestinationSaveResult> {
55 const config = ensureS3Config(rawConfig);
56 const credentials = ensureAwsCredentials(config);
57 const key = buildObjectKey(config, input.fileName);
58
59 const client = new S3Client({
60 region: credentials.region ?? config.region ?? 'us-east-1',
61 endpoint: config.endpoint,
62 forcePathStyle: config.forcePathStyle,
63 credentials: {
64 accessKeyId: credentials.accessKeyId,
65 secretAccessKey: credentials.secretAccessKey,
66 sessionToken: credentials.sessionToken,
67 },
68 });
69
70 context.logger.info(
71 `[Destination:S3] Uploading ${input.fileName} (${input.buffer.byteLength} bytes) to s3://${config.bucket}/${key}`,
72 );
73
74 const command = new PutObjectCommand({
75 Bucket: config.bucket,
76 Key: key,
77 Body: input.buffer,
78 ContentType: input.mimeType,
79 Metadata: {
80 'shipsec-run-id': context.runId,
81 'shipsec-component-ref': context.componentRef,
82 },
83 });
84
85 const response = await client.send(command);
86 const uri = `s3://${config.bucket}/${key}`;
87 const publicUrl = config.publicUrl
88 ? `${config.publicUrl.replace(/\/+$/, '')}/${key}`
89 : undefined;
90
91 return {
92 remoteUploads: [
93 {
94 type: 's3',
95 bucket: config.bucket,
96 key,
97 uri,
98 url: publicUrl,
99 region: credentials.region ?? config.region,
100 etag: typeof response.ETag === 'string' ? response.ETag.replace(/"/g, '') : undefined,
101 },
102 ],
103 };
104 },
105 };
106 },

Callers 15

sidebar-state.tsFile · 0.50
artifactStore.tsFile · 0.50
mcpGroupStore.tsFile · 0.50
runStore.tsFile · 0.50
apiKeyStore.tsFile · 0.50
executionStore.tsFile · 0.50
mcpServerStore.tsFile · 0.50
webhookStore.tsFile · 0.50
workflowUiStore.tsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected