add 上传图片

This commit is contained in:
SummerTail 2023-07-04 19:04:31 +08:00
parent c4c01f007f
commit ba99c5d05b
2 changed files with 33 additions and 10 deletions

View File

@ -8,6 +8,18 @@ const {getMediaInfo} = require("../util/utils");
const router = new Router() const router = new Router()
// const download = [] // const download = []
router.get("/test", async (ctx) => {
await utils.uploadImg('C:\\Users\\SummerTail\\Pictures\\Snipaste_2023-07-03_22-16-37.png')
ctx.body = {
code: 0,
msg: "test",
data: ''
}
})
router.get("/getMediaInfo", async (ctx) => { router.get("/getMediaInfo", async (ctx) => {
let url = ctx.query.filePath let url = ctx.query.filePath
let data let data
@ -50,14 +62,6 @@ router.get("/startDown", async (ctx) => {
} }
}) })
router.get("/test", async (ctx) => {
let rep = await utils.getTencentVideoPlayList('mzc00200t7i1qwp')
ctx.body = {
code: 0,
msg: "test",
data: rep
}
})
// 连接池 // 连接池

View File

@ -1,7 +1,8 @@
const {spawn} = require('child_process'); const {spawn} = require('child_process');
const path = require('path'); const path = require('path');
const {cwd} = require('process'); const {cwd} = require('process');
const {readFile} = require("fs");
const {post} = require("axios");
function seep(time) { function seep(time) {
return new Promise((res) => { return new Promise((res) => {
@ -11,6 +12,23 @@ function seep(time) {
}) })
} }
/**
* 上传图片至图床 暂不可用
* @param filePath 图片路径
*/
function uploadImg(filePath) {
readFile(filePath, function (err, data) {
let formData = new FormData()
formData.append('file', data)
post('https://image.zmpt.cc/upload/localhost', formData).then((response, headers) => {
console.info(response)
})
})
}
/** /**
* 获取腾讯视频播放列表 * 获取腾讯视频播放列表
* @param {String}cid 视频id * @param {String}cid 视频id
@ -148,5 +166,6 @@ module.exports = {
getVideoSpecifyTimeImage, getVideoSpecifyTimeImage,
getMediaInfo, getMediaInfo,
createTorrent, createTorrent,
getTencentVideoPlayList getTencentVideoPlayList,
uploadImg
} }