axios传递数据到java_使用axios将图像上传到Cloudinary

我被困在将文件上传到cloudinary . 服务器抛出错误:无法加载https://api.cloudinary.com/v1_1/example-com/image/upload:请求标头字段预检响应中的Access-Control-Allow-Headers不允许授权 .

handleDrop = files => {

// Push all the axios request promise into a single array

// const uploaders = files.map(file => {

// Initial FormData

const formData = new FormData();

// formData.append("file", file);

formData.append("upload_preset", "232323"); // Replace the preset name with your own

formData.append("api_key", "sadsd"); // Replace API key with your own Cloudinary key

formData.append("timestamp", (Date.now() / 1000) | 0);

// Make an AJAX upload request using Axios (replace Cloudinary URL below with your own)

return axios

.post(

"https://api.cloudinary.com/v1_1/example-com/image/upload",

formData,

{

headers: { "X-Requested-With": "XMLHttpRequest" }

}

)

.then(response => {

const data = response.data;

const fileURL = data.secure_url; // You should store this URL for future references in your app

console.log(data);

});

// });

// Once all the files are uploaded

// axios.all(uploaders).then(() => {

// // ... perform after upload is successful operation

// });

};

您认为这个问题是什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值