【问题标题】:Node Cloudinary Picture Upload not Working in Heroku节点 Cloudinary 图片上传在 Heroku 中不起作用
【发布时间】:2020-03-22 18:17:49
【问题描述】:

我创建了一个 SNS Web 应用程序(使用 node.js),人们可以将图片(使用 cloudinary)上传到集合中。 该应用程序在我用于编写代码的基于云的 IDE 上完美运行;但是,将其推送到 heroku 后,图像上传不再有效。我的控制台中没有收到任何错误消息,即使我认为它应该是 console.logging 它,但是错误闪烁发生并且图像没有上传。

这是我的代码:

router.post("/", middleware.isLoggedIn, upload.single('image'), function(req, res){
	cloudinary.v2.uploader.upload(req.file.path, function(err, result) {
		if (err) {
			//if error
			console.log(err.message);
			req.flash("error", "Can't upload image, try again later.");
			return res.redirect("back");
		}
		//else
		// add cloudinary url for the image to the campground object under image property
		req.body.image = result.secure_url;
		req.body.imageId = result.public_id;
		// add author to campground
		req.body.author = {
			id: req.user._id,
			username: req.user.username
		};

我尝试搜索其他帖子可能是出于某种原因;但我找不到任何符合我情况的东西。如果有人可以帮助...请,您的建议将不胜感激! 谢谢。

【问题讨论】:

    标签: node.js heroku image-uploading cloudinary


    【解决方案1】:

    对不起!问题是 CLOUD_NAME 配置变量周围有 '' 标记。

    如果有人遇到类似问题,请尝试删除 name 变量周围的引号。

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 2021-02-20
      • 2018-11-07
      • 2022-01-12
      • 2016-02-23
      • 2019-04-24
      • 2016-09-20
      • 2016-09-10
      • 2019-05-07
      相关资源
      最近更新 更多