Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 1.6.0

### Added
- Support custom properties in attachments.

### Fixed
- Issue where users were unable to read attachments after uploading them.

## Version 1.5.1

### Fixed
Expand Down
5 changes: 2 additions & 3 deletions lib/handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ async function readDocument(Key, token, uri) {
"&cmisselector=content";
const config = {
headers: { Authorization: `Bearer ${token}` },
responseType: "arraybuffer",
responseType: "stream",
};

try {
const response = await axios.get(documentReadURL, config);
const responseBuffer = Buffer.from(response.data, "binary");
return responseBuffer;
return response.data;
} catch (error) {
if (error.message == "Request failed with status code 404" && error.status == 404){
error.message = "Attachment not found in the repository"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cap-js/sdm",
"description": "CAP plugin for effortless integration of CAP applications with SAP Document Management Service.",
"version": "1.5.2",
"version": "1.6.1",
"repository": "cap-js/sdm",
"author": "SAP SE (https://www.sap.com)",
"homepage": "https://cap.cloud.sap/",
Expand Down
4 changes: 0 additions & 4 deletions test/integration/attachments-sdm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ describe('Attachments Integration Tests --CREATE', () => {
{
filename: "samplebig.pdf",
filepath: "./test/integration/samplebig.pdf"
},
{
filename: "invalid.pdf",
filepath: "./test/integration/invalid.pdf"
}
];

Expand Down
5 changes: 2 additions & 3 deletions test/lib/handler/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe("handlers", () => {
const mockCredentials = { uri: "http://example.com/" };

const mockResponse = { data: "mock pdf file content" };
const mockBuffer = Buffer.from(mockResponse.data, "binary");

axios.get.mockResolvedValue(mockResponse);

Expand All @@ -71,9 +70,9 @@ describe("handlers", () => {
"&cmisselector=content";
expect(axios.get).toHaveBeenCalledWith(expectedUrl, {
headers: { Authorization: `Bearer ${mockToken}` },
responseType: "arraybuffer",
responseType: "stream",
});
expect(document).toEqual(mockBuffer);
expect(document).toEqual(mockResponse.data);
});

it("throws error on unsuccessful read", async () => {
Expand Down