Browse Source
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): 补充遗漏的返回值
pull/3701/head
Electrolux
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
4 deletions
-
apps/test-server/service/FileService.ts
|
|
|
@ -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!', |
|
|
|
}; |
|
|
|
|