feat(gallery): add newly uploaded kitehotel and kitesurf images
This commit is contained in:
@@ -9,26 +9,34 @@ cloudinary.config({
|
||||
});
|
||||
|
||||
const uploadImages = async () => {
|
||||
const publicDir = path.join(__dirname, '..', 'public');
|
||||
const files = fs.readdirSync(publicDir);
|
||||
|
||||
const images = files.filter(file => file.endsWith('.jpg') || file.endsWith('.png'));
|
||||
|
||||
const foldersToUpload = ['kitehotel', 'kitesurf'];
|
||||
const results = {};
|
||||
|
||||
for (const file of images) {
|
||||
console.log(`Uploading ${file}...`);
|
||||
try {
|
||||
const filePath = path.join(publicDir, file);
|
||||
const result = await cloudinary.uploader.upload(filePath, {
|
||||
folder: 'moygrup',
|
||||
use_filename: true,
|
||||
unique_filename: false
|
||||
});
|
||||
console.log(`Uploaded ${file} -> ${result.secure_url}`);
|
||||
results[file] = result.secure_url;
|
||||
} catch (error) {
|
||||
console.error(`Error uploading ${file}:`, error);
|
||||
|
||||
for (const folderName of foldersToUpload) {
|
||||
const publicDir = path.join(__dirname, '..', 'public', folderName);
|
||||
|
||||
if (!fs.existsSync(publicDir)) {
|
||||
console.log(`Directory does not exist: ${publicDir}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(publicDir);
|
||||
const images = files.filter(file => file.endsWith('.jpg') || file.endsWith('.jpeg') || file.endsWith('.png') || file.endsWith('.webp'));
|
||||
|
||||
for (const file of images) {
|
||||
console.log(`Uploading ${folderName}/${file}...`);
|
||||
try {
|
||||
const filePath = path.join(publicDir, file);
|
||||
const result = await cloudinary.uploader.upload(filePath, {
|
||||
folder: `moygrup/${folderName}`,
|
||||
use_filename: true,
|
||||
unique_filename: false
|
||||
});
|
||||
console.log(`Uploaded ${file} -> ${result.secure_url}`);
|
||||
results[`${folderName}/${file}`] = result.secure_url;
|
||||
} catch (error) {
|
||||
console.error(`Error uploading ${folderName}/${file}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user