Downloading Images from the Library with the API

Hello,
I am working with CMS version 2.3.1 and Player 1.8R5.
I am trying to download images from the library with using the API.

When downloading very small images (few KB’s) it is working fine and displaying, but when I am trying to download and display larger images (over 45 KB) it is failing.
I have been trying to make the app wait for the image to download, with no luck,

When I have debugged the process I have noticed a message from the server saying
“Connection closed while receiving data”
When I monitored the chunks of data, I noticed it is loading some part of the image (sometimes as much as 1 byte less than the size of the file…) and then throwing the exception, I even forced the app waiting until the size of data is the expected size, which actually make the app freeze.

I have tried the regular syntax /library/download/{imageId}/{imageType}
and with the /library/download/{imageId}?preview=1, No Luck.

I have tried to add a “Keep-Alive”: “true” pair to the headers of the get request (along with the authorization) and it didn’t help too.

Any help / idea will be appreciated.
Guy

Can you try with a current version CMS first please. 2.3.7 is latest.

Hello,
Thank you for your response.
Upgraded to 2.3.7. - no luck.
Same exception:

  • A small image (few KBs) displayed.
  • On larger, like 50 KBs or more I get the same error: “Connection closed”

Is there a header, similar to “Keep-Alive” I can use with the API while pulling the image?
BR,
Guy

Is this a Docker install? Or Cloud?

If neither, what do you have your Sendfile Mode set to in the CMS settings?

Can you give the complete API call you’re making please.

Can you check if you can download the same file from the library using the Download button?

Is this a Docker install? Or Cloud?
It is a Docker install on premise, on Linux ,

If neither, what do you have your Sendfile Mode set to in the CMS settings?
Checked the SENDFILE_MODE in the database, it is configured as apache.

Can you give the complete API call you’re making please.
the api get command is
/api/library/download/{mediaId}
Of course, I have authorization header.

**reminder: some of the files (the smallest) are successfully retrieved by my mobile application with the api call.

Can you check if you can download the same file from the library using the Download button?
I have successfully downloaded files from the CMS itself to my PC.

Thanks
Guy

Could you show me a code snippet related to downloading and showing the image please?
Feel free to send me a private message if that’s more suitable.

Just to confirm, that it generally works correctly, I’ve set up a quick test that uses Guzzle client to download the image from CMS (couple MB in size) just in case also not only form my local dev cms, but from one of our Cloud CMS instances as well and it seems to work just fine, the image is fully downloaded.

For the test I used simple Guzzle client to download the image, with code like this:

$guzzle= new GuzzleHttp\Client();
$guzzle->request('GET', $cmsAddress . '/api/library/download/' . $mediaId. '/' . 'image', [
    'sink' => 'testMedia.png',
    'headers' => ['Authorization' => 'Bearer ' . $token]
]);