forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-video.ts
More file actions
58 lines (48 loc) · 1.62 KB
/
Copy pathupload-video.ts
File metadata and controls
58 lines (48 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { readFileSync } from "fs";
import { basename } from "path";
export interface VideoToUpload {
s3ObjectPath: string;
videoPath: string;
}
export async function uploadVideos(videos: VideoToUpload[]) {
if (!process.env.GITHUB_ACTIONS_RUN_ID) {
console.log("Not uploading videos because not in GitHub Actions");
return;
}
// const accessKeyId = process.env.AWS_ACCESS_KEY_ID as string;
// const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY as string;
// if (!accessKeyId || !secretAccessKey) {
// console.error("AWS credentials not configured - skipping video upload");
// return;
// }
const s3Client = new S3Client({
region: "us-east-1",
// credentials: {
// accessKeyId,
// secretAccessKey,
// },
});
if (!videos.length) return;
console.log(`Uploading ${videos.length} test videos to S3...`);
try {
const uploadPromises = videos.map(async (video) => {
console.log(`Uploading video: ${video.s3ObjectPath}`);
const fileContent = readFileSync(video.videoPath);
const command = new PutObjectCommand({
Bucket: "copilotkit-e2e-test-recordings",
Key: video.s3ObjectPath,
Body: fileContent,
ContentType: "video/webm",
});
await s3Client.send(command);
console.log(`Uploaded video: ${basename(video.videoPath)}`);
});
await Promise.all(uploadPromises);
console.log("Uploaded all videos");
return;
} catch (error) {
console.error("Failed to upload videos:", error);
throw error; // Rethrow to handle in reporter
}
}