fix(koa->upload): fix the error that occurs when uploading files in the test server of Koa. (#3698)

* fix(koa->upload): 修复koa上传文件的报错

* fix(koa->upload): 补充遗漏的返回值

* fix(koa->upload): 补充遗漏的返回值
This commit is contained in:
Electrolux 2024-03-28 10:28:55 +08:00 committed by GitHub
parent 05030ee984
commit 954f04f1c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,8 +10,8 @@ export default class FileService {
let fileReader, fileResource, writeStream;
const fileFunc = function (file) {
fileReader = fs.createReadStream(file.path);
fileResource = filePath + `/${file.name}`;
fileReader = fs.createReadStream(file.filepath);
fileResource = filePath + `/${file.originalFilename}`;
console.log(fileResource);
writeStream = fs.createWriteStream(fileResource);
@ -22,7 +22,7 @@ export default class FileService {
if (flag) {
let url = '';
for (let i = 0; i < files.length; i++) {
url += uploadUrl + `/${files[i].name},`;
url += uploadUrl + `/${files[i].originalFilename},`;
}
url = url.replace(/,$/gi, '');
ctx.body = {
@ -32,7 +32,7 @@ export default class FileService {
};
} else {
ctx.body = {
url: uploadUrl + `/${files.name}`,
url: uploadUrl + `/${files.originalFilename}`,
code: 0,
message: 'upload Success!',
};