
[英]Cloudinary image upload from React: am including Cloudinary unsigned preset but get “Upload preset must be specified when using unsigned upload”
[英]"Upload preset must be specified when using unsigned upload" when trying to upload image from React to cloudinary
即使在 cloudinary->settings->upload->Upload presets 中将 Signing Mode 设置为 unsigned 后,也会出现此错误:“使用未签名上传时必须指定上传预设”。 这是我的参考代码:
const cloudinaryData = new FormData();
cloudinaryData.append("file", img);
cloudinaryData.append("upload_preset", "preset-name");
cloudinaryData.append("cloud_name", process.env.REACT_APP_CLOUDINARY_CLOUD_NAME);
console.log(cloudinaryData);
axios.post(`https://api.cloudinary.com/v1_1/${process.env.REACT_APP_CLOUDINARY_CLOUD_NAME}/upload`, {
body: cloudinaryData,
})
.then(res => {
res.json();
console.log("from then", res);
})
.catch(err => {
console.log("from catch", err);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.