2021-11-15小书匠上绑定cheveroto图床

2021-11-15小书匠上绑定cheveroto图床

一、小书匠关于自定义绑定图床

1. chevero的开cors设置

cheveroto在我的服务中使用apache服务,在.htaccess文件中加入以下配置

  1. Header add Access-Control-Allow-Origin: "http://markdown.xiaoshujiang.com" 

2. 小书匠的自定义图床设置如下:

在小书匠客户端绑定的时候一直报错,去网页版查看f12里console的信息,原来是跨域cors问题

  1. const fd = new FormData(); 
  2. fd.append('source', new File([fileData], filename)); 
  3. $.ajax({ 
  4. type: 'POST', 
  5. url: 'http://XXXX.com/api/1/upload/?key=***********', 
  6. data: fd, 
  7. processData: false, 
  8. contentType: false 
  9. }).done(function(data){ 
  10. try{ 
  11. data = JSON.parse(data); 
  12. } catch(e){} 
  13. if (data.status_code != 200) { 
  14. callback('上传失败' + data.message); 
  15. } else { 
  16. callback(null, data.image.filename, data.image.url, data); 
  17. } 
  18. }).fail(function(res, status, message){ 
  19. callback('上传资源失败:' + message); 
  20. }); 

3. cheveroto中的api key查找

去搭建的cheveroto管理员主页通过dashboard-settings-api中查找

enter description here
enter description here

posted @ 2021-11-15 16:07  sxl7777  阅读(43)  评论(0编辑  收藏  举报