Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
translation-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinmingyuan
translation-server
Commits
5e032adb
Commit
5e032adb
authored
Jan 24, 2025
by
mingyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:暂时恢复流文件下载
parent
9b01570a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
translate.service.ts
src/controller/translate/translate.service.ts
+6
-6
No files found.
src/controller/translate/translate.service.ts
View file @
5e032adb
...
@@ -200,15 +200,15 @@ export class TranslateService {
...
@@ -200,15 +200,15 @@ export class TranslateService {
throw
BadRequestError
.
default
(
'下载翻译图片失败'
);
throw
BadRequestError
.
default
(
'下载翻译图片失败'
);
}
}
//
//
设置响应头
// 设置响应头
//
res.setHeader('Content-Type', 'image/jpeg'); // 根据实际文件类型设置
res
.
setHeader
(
'Content-Type'
,
'image/jpeg'
);
// 根据实际文件类型设置
//
res.setHeader('Content-Disposition', 'attachment; filename="image.jpg"'); // 设置下载文件名
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename="image.jpg"'
);
// 设置下载文件名
//
//
将文件流返回给前端
// 将文件流返回给前端
//
response.data.pipe(res);
response
.
data
.
pipe
(
res
);
// 上传图频到服务器
// 上传图频到服务器
return
await
this
.
uploadStream
(
response
.
data
);
//
return await this.uploadStream(response.data);
}
}
async
uploadStream
(
stream
)
{
async
uploadStream
(
stream
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment