From ce86845654592a1c0a5b40ecb68b47b59e008d35 Mon Sep 17 00:00:00 2001 From: "Yashmeet ." Date: Wed, 2 Jul 2025 15:38:35 +0530 Subject: [PATCH 1/2] Fix for read attachment, UTs & Integration tests --- lib/handler/index.js | 5 ++--- test/integration/attachments-sdm.test.js | 4 ---- test/lib/handler/index.test.js | 5 ++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/handler/index.js b/lib/handler/index.js index 2e4b98df..20778b99 100644 --- a/lib/handler/index.js +++ b/lib/handler/index.js @@ -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" diff --git a/test/integration/attachments-sdm.test.js b/test/integration/attachments-sdm.test.js index d87662c8..3fee43e6 100644 --- a/test/integration/attachments-sdm.test.js +++ b/test/integration/attachments-sdm.test.js @@ -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" } ]; diff --git a/test/lib/handler/index.test.js b/test/lib/handler/index.test.js index 03a55c25..18c34faf 100644 --- a/test/lib/handler/index.test.js +++ b/test/lib/handler/index.test.js @@ -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); @@ -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 () => { From 9341d74a300410c2dd24db743c2e8664f714d24c Mon Sep 17 00:00:00 2001 From: "Yashmeet ." Date: Wed, 2 Jul 2025 19:28:34 +0530 Subject: [PATCH 2/2] ChangeLog & Version update --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af0aea4..db1580d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 26c6191e..80060715 100644 --- a/package.json +++ b/package.json @@ -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/",