add category banner image
This commit is contained in:
parent
109c213e9c
commit
b61436183b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
.env
|
||||
tmp
|
@ -114,14 +114,13 @@ export const updateCategory = async (req, res) => {
|
||||
};
|
||||
}
|
||||
if (req.files.category_banner) {
|
||||
if (categ.category_banner) {
|
||||
if (categ.category_banner.public_id) {
|
||||
const imageId = categ.category_banner.public_id;
|
||||
// console.log(imageId)
|
||||
|
||||
//delete image from claudinary
|
||||
await cloudinary.uploader.destroy(imageId)
|
||||
}
|
||||
|
||||
// await cloudinary.uploader.destroy(imageId, function (result) { console.log(result) });
|
||||
const files = req.files.category_banner;
|
||||
const BannerImage = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||
folder: "image",
|
||||
@ -138,6 +137,7 @@ export const updateCategory = async (req, res) => {
|
||||
|
||||
}
|
||||
// console.log(newCategoryData)
|
||||
|
||||
//req.user.id,
|
||||
const ModifyCategory = await Category.findByIdAndUpdate(req.params.id, newCategoryData,
|
||||
|
||||
|
@ -20,11 +20,11 @@ const categorySchema = new mongoose.Schema(
|
||||
{
|
||||
public_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
// required: true,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
// required: true,
|
||||
},
|
||||
},
|
||||
addedOn: {
|
||||
|
Loading…
Reference in New Issue
Block a user