[Code] fix binary file download (#47650) (#47680)

This commit is contained in:
Yulong 2019-10-09 20:42:45 +08:00 committed by GitHub
parent de271780fc
commit 9f68adf230
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -49,7 +49,7 @@ export const GitServiceDefinition = {
request: {} as FileLocation,
response: {} as {
isBinary: boolean;
content: string;
content: Buffer;
},
},
history: {
@ -140,7 +140,7 @@ export const getGitServiceHandler = (
const isBinary = blob.isBinary();
return {
isBinary,
content: blob.content().toString(),
content: blob.content(),
};
},
async history({ uri, path, revision, count, after }) {

View file

@ -133,7 +133,7 @@ export function fileRoute(router: CodeServerRouter, codeServices: CodeServices)
try {
const blob = await gitService.raw(endpoint, { uri: repoUri, path, revision });
if (blob.isBinary) {
return h.response(blob.content).type('application/octet-stream');
return h.response(blob.content).encoding('binary');
} else {
return h.response(blob.content).type('text/plain');
}