fix file upload

This commit is contained in:
Brandon Egger 2023-08-22 12:55:01 -05:00
parent 2c3d53f317
commit 4dbc46c1c0
2 changed files with 3 additions and 6 deletions

View File

@ -60,7 +60,9 @@ const handler: NextApiHandler = async (req, res) => {
}, },
data: { data: {
photo: { photo: {
name: getFileName((await uploadPhoto).filepath), name: getFileName(
(await uploadPhoto).originalFilename ?? "resource ICON"
),
data: photoBuffer, data: photoBuffer,
}, },
}, },

View File

@ -60,9 +60,6 @@ const EditResourcePage = (
}); });
const onSubmit: SubmitHandler<ResourceUpdateInput> = async (data) => { const onSubmit: SubmitHandler<ResourceUpdateInput> = async (data) => {
// TODO: Fix file upload, currently it is not updating correctly on the server side
// May also need to look into re-rendering static pages when icon changes
// Also need to add authentication of route!
if (updateIconFile) { if (updateIconFile) {
const data = new FormData(); const data = new FormData();
data.append("photo", updateIconFile); data.append("photo", updateIconFile);
@ -75,8 +72,6 @@ const EditResourcePage = (
} }
); );
console.log("uploading icon");
if (uploadResponse.status !== 200) { if (uploadResponse.status !== 200) {
setServerError( setServerError(
"Failed uploading resource icon file. Changes did not save!" "Failed uploading resource icon file. Changes did not save!"