cancel
Showing results for 
Search instead for 
Did you mean: 

Download File from DMS using Custom API

0 Kudos
1,273

Hello Collogues,

We are creating custom API on DMS Service where we wanted to download file from DMS.

I am able to read file in raw format but not able to convert and download in local Machine .

Can someone suggest how to convert and download?

Custom API is written in NodeJS.

Here is the format of file we are getting from DMS.

View Entire Topic
Willem_Pardaens
Product and Topic Expert
Product and Topic Expert

CAP will interpret any retrieved file as UTF-8 while this is not always matching the codeset of your file. You can use the underlying SAP Cloud SDK to bypass this UTF-8 conversion as it allows you to specify the Response Type to be the raw buffer and you can handle it the way you want (e.g. for images):

const { OpenApiRequestBuilder } = require('@sap-cloud-sdk/openapi');
const fileBuffer = await new OpenApiRequestBuilder('GET', '/browser/repo/root?objectId=abcd')
  .addCustomRequestConfiguration({ responseType: 'arraybuffer' })
  .execute({ destinationName: 'SDM_Destination' });

'downloading to local machine' would then require a UI, for which you could look at the UI5 component here: https://blogs.sap.com/2021/08/18/my-journey-towards-using-ui5-uploadset-with-cap-backend/

cdan
Explorer
0 Kudos
Thank you so much. It solved my major problem