Skip to content

Commit 1f5b34d

Browse files
committed
Fix two small bugs with the RestAPI Datasource
First bug: Spring automatically transforms binary content to base64, therefore the logic in the RestApiExecutor was causing the data to be encoded twice, causing much confusion and frustration for several weeks actually. Second bug: the fileUtils#saveDataAsFile function was not actually setting the type correctly when attempting to convert the base64 data to a binary blob, thus the files would _always_ download as a 'dms' file and it would never actually be openable. This also caused a lot of confusion. Both of these bugs together made it impossible to tell why stuff was broken. Combined this means that anytime you were trying to download binary data you would never actually be able to open the file, as it would be only base64 data inside of it.
1 parent 42be426 commit 1f5b34d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

client/packages/lowcoder/src/util/fileUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function saveDataAsFile({ data, filename, fileType, dataType }: Sav
4848

4949
if (dataType === "base64") {
5050
const blob = new Blob([Buffer.from(data, "base64")], {
51-
type: mime + ";charset=utf-16",
51+
type: mim + ";charset=utf-16",
5252
});
5353
return saveAs(blob, filename, { autoBom: true });
5454
}

server/api-service/lowcoder-plugins/restApiPlugin/src/main/java/org/lowcoder/plugin/restapi/RestApiExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private ResponseBodyData parseResponseDataInfo(byte[] body, MediaType contentTyp
426426
}
427427
if (isBinary(contentType)) {
428428
return ResponseBodyData.builder()
429-
.body(Base64.getEncoder().encode(body))
429+
.body(body)
430430
.dataType(ResponseDataType.BINARY)
431431
.build();
432432
}

0 commit comments

Comments
 (0)