upload_video.js 611 B

1234567891011121314151617181920212223
  1. const { baseUrl } = require("../request/request");
  2. //单视频上传 file为上传文件暂存地址对象
  3. const api = '/upload/video'
  4. const upload_video = (file) => {
  5. return new Promise((reslove) => {
  6. wx.uploadFile({
  7. url: baseUrl + api,
  8. filePath: file.url,
  9. name: 'file',
  10. success(res) {
  11. reslove({ ...file, url: baseUrl+'/'+JSON.parse(res.data).data, relative_url: JSON.parse(res.data).data})
  12. },
  13. fail (err) {
  14. wx.showToast({
  15. title: '视频上传没有成功哦,再试一次吧~',
  16. })
  17. }
  18. });
  19. })
  20. }
  21. module.exports = upload_video