Add size to the file
This commit is contained in:
parent
4bc2fc4f67
commit
75b5c56190
@ -5,13 +5,13 @@ import { getUserByUploadKey } from "../../../utils/helpers/userHelpers";
|
|||||||
|
|
||||||
const apiRoute = nextConnect({
|
const apiRoute = nextConnect({
|
||||||
onError(error, req, res) {
|
onError(error, req, res) {
|
||||||
res.status(501).json({
|
res.status(200).json({
|
||||||
message: `An internal server error has occured. Please check console.`,
|
message: `An internal server error has occured. Please check console.`,
|
||||||
});
|
});
|
||||||
console.log(error);
|
console.log(error);
|
||||||
},
|
},
|
||||||
onNoMatch(req, res) {
|
onNoMatch(req, res) {
|
||||||
res.status(405).json({ message: `Method "${req.method}" Not Allowed` });
|
res.status(200).json({ message: `Method "${req.method}" Not Allowed` });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ apiRoute.post(async (req, res) => {
|
|||||||
}
|
}
|
||||||
const { originalname: filename, mimetype, buffer, size } = file;
|
const { originalname: filename, mimetype, buffer, size } = file;
|
||||||
const { secret } = req.body;
|
const { secret } = req.body;
|
||||||
console.log(secret);
|
|
||||||
|
|
||||||
const user = await getUserByUploadKey(secret);
|
const user = await getUserByUploadKey(secret);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@ -37,7 +36,7 @@ apiRoute.post(async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = await createFile(user, filename, buffer, mimetype);
|
const id = await createFile(user, filename, buffer, mimetype, size);
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
message: `${process.env.NEXT_PUBLIC_SITE_URL}/files/${id}`,
|
message: `${process.env.NEXT_PUBLIC_SITE_URL}/files/${id}`,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user