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