download.js 851 B

123456789101112131415161718192021222324252627282930313233
  1. const axios = require("axios");
  2. module.exports = download;
  3. /**
  4. * 获取文件下载连接
  5. * @param {String} id 文件id
  6. * @param {String} cookie 请求Cookie
  7. * @param {String|Boolean}
  8. */
  9. async function download(id, cookie) {
  10. var url = `https://mo.own-cloud.cn/api/v3/file/download/${id}`;
  11. var headers = {
  12. 'cookie': cookie,
  13. 'referer': 'https://mo.own-cloud.cn/',
  14. 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
  15. }
  16. try {
  17. var res = await axios({
  18. method: 'PUT',
  19. url: url,
  20. headers: headers
  21. })
  22. } catch {
  23. console.log("请求失败!");
  24. return false;
  25. }
  26. if (res.data.code == 0) {
  27. return res.data.data;
  28. } else {
  29. return false;
  30. }
  31. }