[英]Meteor How to upload files to cloudinary using lepozepo:cloudinary Firefox?
我已經在stackoverflow上搜索了這個問題,但是它們看上去都差不多(實際上不是同一問題),而有些卻完全相反。
這是我的代碼:
Cloudinary.upload(file, {
folder: "images",
type: "private"
}, (err, res) => {
if(err) {
console.log("Upload Error: ", err);
alert("Sorry, there was an error uploading the image");
return;
}
if (res) {
console.log("Upload Result: ", res);
}
});
上面的代碼適用於Safari和Chrome,但在Firefox上無法使用。 它讓我發瘋!
Firefox拋出錯誤說:
File.lastModifiedDate is deprecated. Use File.lastModified instead.
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data[Learn More] lepozepo_cloudinary.js:224:20
Cloudinary._upload_file/</<
不知道這里是什么問題,請提供任何幫助。 謝謝。
嘗試這種方法。 在Cloudinary管理員的“設置”下的“上傳”下。 在有符號或無符號之間選擇
客戶
$.cloudinary.config({
cloud_name: 'your-cloud-name',
api_key: '1234xxxxxxxxxx'
});
let files = event.currentTarget.your_form_field_name.files;
return Cloudinary.upload(files, {
}, function(err, res) {
if (err) {
console.error(err);
} else {
/** Do something with the response **/
});
服務器
//cloudinary
Cloudinary.config({
cloud_name: 'your-cloud-name',
api_key: '1234xxxxxxxx',
api_secret: '5678xxxxxxxx'
});
Cloudinary.rules.signature = function() {
return this.userId;
};
請注意,如果您正在執行未簽名的請求,則可能不需要簽名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.