updating how I am reading images
Build and Push Image / build-and-push (push) Successful in 1m19s

This commit is contained in:
2026-04-29 22:17:03 -07:00
parent 0687ff9610
commit 8ad813e4f4
+4 -4
View File
@@ -99,7 +99,7 @@ async function downloadTcgImage(productId, imageUrl) {
return {}; return {};
} }
} }
const applyImageToItem = async (itemId, localImagePath, token) => { const applyImageToItem = async (itemId, localImagePath, fileName, token) => {
try { try {
console.log(`Local Image Path: ${localImagePath}`); console.log(`Local Image Path: ${localImagePath}`);
@@ -109,7 +109,7 @@ const applyImageToItem = async (itemId, localImagePath, token) => {
} }
const formData = new FormData(); const formData = new FormData();
formData.append(localImagePath, fs.readFileSync(localImagePath)); formData.append('image', fs.readFileSync(localImagePath), filename);
const response = await fetch(`${koillectionBaseUrl}/items/${itemId}/image`, { const response = await fetch(`${koillectionBaseUrl}/items/${itemId}/image`, {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -211,7 +211,7 @@ const createCollectionFromCSV = async (name, csvFilePath) => {
// Await each download before starting the next // Await each download before starting the next
// const { destination } = await downloadTcgImage(productId, item.imageUrl); // const { destination } = await downloadTcgImage(productId, item.imageUrl);
item.itemIds.forEach((id) => itemIdImageLocations.push({ itemId: id, imageDest: path.join(imagesDir, `${productId}.jpg`) })); item.itemIds.forEach((id) => itemIdImageLocations.push({ itemId: id, imageDest: imagesDir, fileName: `${productId}.jpg` }));
} }
// After processing all collections, check the imagesDir // After processing all collections, check the imagesDir
@@ -221,7 +221,7 @@ const createCollectionFromCSV = async (name, csvFilePath) => {
console.log(`Item ID Image Locations: ${JSON.stringify(itemIdImageLocations, null, 2)}`); console.log(`Item ID Image Locations: ${JSON.stringify(itemIdImageLocations, null, 2)}`);
// Process multiple images concurrently using Promise.all() // Process multiple images concurrently using Promise.all()
const promises = itemIdImageLocations.map(async (item) => { const promises = itemIdImageLocations.map(async (item) => {
await applyImageToItem(item.itemId, item.imageDest, token); await applyImageToItem(item.itemId, item.imageDest, item.fileName, token);
}); });
await Promise.all(promises); await Promise.all(promises);
}; };