import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import dotenv from 'dotenv';

dotenv.config();

async function uploadTestFile() {
	const client = new S3Client({
		region: 'auto',
		endpoint: `https://${process.env.CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`,
		credentials: {
			accessKeyId: process.env.CLOUDFLARE_R2_ACCESS_KEY_ID!,
			secretAccessKey: process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY!
		}
	});

	const command = new PutObjectCommand({
		Bucket: 'neoad',
		Key: 'clients/annonceurs/graphik-factory-12378965487546/test-file.txt',
		Body: Buffer.from('Fichier de test - ' + new Date().toISOString()),
		ContentType: 'text/plain'
	});

	await client.send(command);
	console.log('✅ Fichier test uploadé dans graphik-factory-12378965487546/');
}

uploadTestFile().catch(console.error);
