cancel
Showing results for 
Search instead for 
Did you mean: 

File uploading in DMS via SAP CAP -- Error - File not supported

sandeepmalhotra
Participant
0 Kudos

Hello Everyone

I successfully uploaded the file in DMS service using SAP CAP (nodejs) but when I try to open the file ( after downloading using SAP UI5 app ) I got error error "file not supported".

Code Snippet

I referred the code mentioned in

https://github.com/gregorwolf/bookshop-demo/blob/main/srv/dms-service.js

vitaly_kozyura
Participant
0 Kudos

Hi, For media files (upload and download using streaming) you can use CAP generics: https://cap.cloud.sap/docs/guides/media-data instead of writing streams on your own. Best regards, Vitaly

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor
0 Kudos

Hi Sandeep,

maybe my example in srv/dms-service.js#L217 helps you. I've used the SAP Cloud SDK to read the data as there I can set responseType: "arraybuffer".

CU
Gregor

sandeepmalhotra
Participant
0 Kudos

Hello gregorw

Thanks for your revert. I am attempting to upload a file into root folder via odata service .

FYR have attached the source code

In the code attached ,I am directly passing the Passthrough Stream in the form object. Unfortunately file get uploaded with 0 bytes.

Also I tried converting the stream object into array buffer , but file get uploaded with 1 byte.

In both cases file contents get lost somewhere .

Do let me know where I am doing wrong.

Thanks

Sandeep

gregorw
Active Contributor
0 Kudos

Please check the code in my linked sample.

Answers (2)

Answers (2)

sandeepmalhotra
Participant
0 Kudos

gregorwolf

I found the cause Earlier i was selecting Form-Data in Postman.

When i tested using binary option ( in Postman)

FYR screenshot attached

Thanks for your assistance

sandeepmalhotra
Participant
0 Kudos

Hello Gregor

I tried and found that below mentioned are added in image file

----------------------------519194166877907121962900

Content-Disposition: form-data; name="content"; filename="Test.png"

Content-Type: image/png

screenshot

image.png

Will investigate further to see how it is added

Thanks

Sandeep