mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
feat(cloud): 支持临时文件上传功能
- 使用 crypto 模块替换 md5 模块进行文件哈希计算 - 添加对临时文件上传的支持,当存在 tempFilePath 时使用文件流处理 - 实现临时文件的 MD5 计算和元数据解析功能 - 在上传完成后自动清理临时文件 - 配置服务器端文件上传中间件启用临时文件支持 - 修改上传插件以支持临时文件读取流上传方式 - 增加文件大小获取和验证的兼容性处理
This commit is contained in:
+10
-1
@@ -1,4 +1,5 @@
|
||||
const { default: axios } = require('axios')
|
||||
const fs = require('fs')
|
||||
const createOption = require('../util/option.js')
|
||||
const logger = require('../util/logger.js')
|
||||
module.exports = async (query, request) => {
|
||||
@@ -71,6 +72,14 @@ module.exports = async (query, request) => {
|
||||
}
|
||||
}
|
||||
|
||||
const useTempFile = !!query.songFile.tempFilePath
|
||||
let uploadData
|
||||
if (useTempFile) {
|
||||
uploadData = fs.createReadStream(query.songFile.tempFilePath)
|
||||
} else {
|
||||
uploadData = query.songFile.data
|
||||
}
|
||||
|
||||
try {
|
||||
await axios({
|
||||
method: 'post',
|
||||
@@ -81,7 +90,7 @@ module.exports = async (query, request) => {
|
||||
'Content-Type': 'audio/mpeg',
|
||||
'Content-Length': String(query.songFile.size),
|
||||
},
|
||||
data: query.songFile.data,
|
||||
data: uploadData,
|
||||
maxContentLength: Infinity,
|
||||
maxBodyLength: Infinity,
|
||||
timeout: 300000,
|
||||
|
||||
Reference in New Issue
Block a user