繁体   English   中英

尝试将图像从 React 上传到 cloudinary 时,“使用未签名上传时必须指定上传预设”

[英]"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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM