2017-01-31 28 views
0

我已經搜索了這個問題的stackoverflow,但他們都似乎相似(不是實際上相同的問題),而有些人有完全相反的問題。流星如何使用lepozepo上傳文件到cloudinary:cloudinary Firefox?

這裏是我的代碼:

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。它讓我瘋狂!

火狐拋出一個錯誤說:

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/</< 

不知道什麼這裏的問題是,任何幫助apprecieated。謝謝。

回答

0

試試這種方法。在「上傳」下的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; 
}; 

注意,如果你正在做的簽名請求

+0

嘿,你可能不需要簽名,謝謝之間進行選擇爲了迴應,我嘗試了這種方法仍然在Firefox上得到錯誤。你在使用lepozepo:cloudinary插件嗎? – Junior

+1

哦,看起來像Moziila正在取消那部分API。 Lepozepo將不得不更新他的包裹。 – NicholasByDesign

+0

是的,它看起來像任何解決方法? – Junior