ai-chatbot/scripts/upload-official-model-avatars.ts

37 lines
943 B
TypeScript

import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { uploadFile } from '../lib/storage/service';
const inputDir = process.argv[2];
if (!inputDir) {
throw new Error('Usage: tsx scripts/upload-official-model-avatars.ts <avatar-directory>');
}
const brands = [
'google',
'openai',
'qwen',
'runway',
'bfl',
'stepfun',
'volcengine',
'doubao',
] as const;
async function main() {
const uploaded: Record<string, string> = {};
for (const brand of brands) {
const file = await readFile(path.join(inputDir, `${brand}.png`));
const arrayBuffer = file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength) as ArrayBuffer;
const result = await uploadFile(`official-model-avatar-${brand}.png`, arrayBuffer);
uploaded[brand] = result.url;
}
console.log(JSON.stringify(uploaded, null, 2));
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});