Files
muglasurucukursu/upload-remaining.js
mstfyldz dbf13ee382 feat: migrate all images to Cloudinary CDN
- Uploaded 42 active images to Cloudinary with auto optimization
- Removed 72 unused theme placeholder images
- Deleted local images/ directory entirely
- All images now served via Cloudinary CDN with f_auto,q_auto
2026-05-04 21:07:49 +03:00

54 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
require('dotenv').config();
const cloudinary = require('cloudinary').v2;
const fs = require('fs');
const path = require('path');
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
const FOLDER = 'muglasurucukursu';
const LOCAL_DIR = path.join(__dirname, 'images');
async function uploadAll() {
const files = fs.readdirSync(LOCAL_DIR).filter(f => {
const stat = fs.statSync(path.join(LOCAL_DIR, f));
return stat.isFile() && /\.(jpg|jpeg|png|svg|webp)$/i.test(f);
});
console.log(`📸 ${files.length} resim bulundu. Yükleme başlıyor...\n`);
const results = {};
for (const file of files) {
const filePath = path.join(LOCAL_DIR, file);
const publicId = `${FOLDER}/${path.parse(file).name}`;
try {
const result = await cloudinary.uploader.upload(filePath, {
public_id: publicId,
overwrite: true,
resource_type: 'image',
});
results[file] = result.secure_url;
const sizeKB = (fs.statSync(filePath).size / 1024).toFixed(0);
console.log(`${file} (${sizeKB}KB) → ${result.secure_url}`);
} catch (err) {
console.error(`${file} yüklenemedi:`, err.message);
}
}
// URL mapping'i kaydet
fs.writeFileSync(
path.join(__dirname, 'cloudinary-urls-images.json'),
JSON.stringify(results, null, 2)
);
console.log(`\n🎉 ${Object.keys(results).length}/${files.length} resim yüklendi.`);
}
uploadAll();