-
Thank you for the update. Unfortunately, we are trying to fire this request from a NodeJS app, where the WebApi interfaces are not available. I tried using substitutes, adding NodeJs buffers or ReadStream,
const patientPhotoKey = await documentsManager.uploadDocument({ type: 'general_public', mimeType: 'image/jpeg', file: fs.createReadStream('./test-pcr-resultat-covid.jpg'), <== This is taken from the form-data library that you are using internally accountId, });But the endpoint always reject me with a 400: Malformed body request:
'<Error><Code>MalformedPOSTRequest</Code><Message>The body of your POST request is not well-formed multipart/form-data.</Message><BucketName>muna-platforms-identity-jovial-albattani</BucketName><Resource>/muna-platforms-identity-jovial-albattani</Resource><RequestId>1657B6AE7E360293</RequestId><HostId>9ec88940-02ae-4bfb-bb47-1811aa632a24</HostId></Error>'Can you please assist on this matter?
-
☠️ @napalmpapalamHi!
const patientPhotoKey = await documentsManager.uploadDocument({ type: 'general_public', mimeType: 'image/jpeg', file: fs.createReadStream('./test-pcr-resultat-covid.jpg'), <== This is taken from the form-data library that you are using internally accountId, });There you are trying to send the stream that reads the file, not the file, and function in the document manager, that uploads file on bucket is trying to create FormData object before upload and it fails because file format is not correct. Try to make ArrayBuffer with this solution
Edited by Semen Loktionov -
Taken from the FormData docs: [https://github.com/form-data/form-data], you can indeed append a stream to your formdata object. In my example, the request is indeed fired to your server, the 400 response comes from the file storage. I tried playing around with other implementations of the WebApi ArrayBuffer class, or simply to pass a buffer but it seems that you can only append streamable content, else i get a
source.on is not a functionfrom the CombinedStream library used internally by FormData.Anyway, since i really cannot find a way to make it work on our end, can you please provide a working example for NodeJs, uploading this file for example: https://nodejs.org/static/legacy/images/logo.png.
Thank you for your support.
-
☠️ @napalmpapalamHello!
First things first, our domain url changed, snippets have been already updated, now urls don't include
.platforms..Second, I implemented the flow of uploading the documents with Node.js, that helped us to research the problem and found an issue in our js-sdk (thanks a lot for it!) and we have been already resolved it, so now you can use the latest version (
1.14.0-rc.12) and for uploading file I usedfs.readFileSyncto read the file like in attached screenshot, and it works.I hope that it will help you.
-
Hello and thank you for your response. I am glad i could spot this issue. The upload is indeed now working and i managed to execute almost your whole snippet successfully, up to the last step: posting the operation. The transaction is failed, probably because of an authentication problem, but nothing else is giving me any hints on the actual issue. I tried to play around with the parameters and still could not get past this 400.
Here is the snippet of the actual code used, can you please assist? https://gitlab.com/-/snippets/2060488
Please register or sign in to comment
