Profile pic Nodejs
Hi, i made this code for my app to upload a user profile picture.
But i do not want the image to be a new version... How to fix that?
app.post('/profile/pic', isLoggedIn, [multer({ dest: './temp/'})], function(req, res) {
cloudinary.uploader.upload(req.files.displayImage.path, function(result) {
fs.unlink(req.files.displayImage.path, function (err) {
if (err) throw err;
req.user.local.profilePic = result.version;
req.user.save(function(err) {
res.redirect('/profile');
});
});
},
{
public_id: req.user._id,
folder: 'profile',
allowed_formats: 'jpg',
overwrite: true
});
});
-
I'm sorry for my response delay.
When passing the
public_id
parameter, the new upload overwrites the image, and the image being stored in Cloudinary is the new one. However, accessing the exact same URL of the image may still result the old image as the image may be cached in the CDN. For more information:
http://support.cloudinary.com/hc/en-us/articles/202520852-How-can-I-update-an-already-uploaded-image-0
Post is closed for comments.
Comments
1 comment