fix: actually write image
This commit is contained in:
@@ -41,7 +41,6 @@ export async function getLogs() {
|
|||||||
date: new Date(date),
|
date: new Date(date),
|
||||||
} as Log;
|
} as Log;
|
||||||
});
|
});
|
||||||
console.log(logs);
|
|
||||||
|
|
||||||
// Return the logs sorted by date
|
// Return the logs sorted by date
|
||||||
return logs.sort((a, b) => a.date.getTime() - b.date.getTime());
|
return logs.sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ export async function createResource(
|
|||||||
body: isJson ? JSON.stringify(content) : content,
|
body: isJson ? JSON.stringify(content) : content,
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to create resource: ${response.status}`);
|
throw new Error(
|
||||||
|
`Failed to create resource (resources/${path}) : ${response.status}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ async function processCreateArticle(
|
|||||||
let finalPath = result.image;
|
let finalPath = result.image;
|
||||||
if (result?.image) {
|
if (result?.image) {
|
||||||
const extension = fileExtension(result?.image);
|
const extension = fileExtension(result?.image);
|
||||||
const imagePath = `resources/articles/images/${
|
const imagePath = `articles/images/${
|
||||||
safeFileName(title)
|
safeFileName(title)
|
||||||
}_cover.${extension}`;
|
}_cover.${extension}`;
|
||||||
try {
|
try {
|
||||||
@@ -63,7 +63,7 @@ async function processCreateArticle(
|
|||||||
await createResource(imagePath, buffer);
|
await createResource(imagePath, buffer);
|
||||||
finalPath = imagePath;
|
finalPath = imagePath;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Failed to save image", err);
|
console.log(`Failed to save image: ${result.image}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user