Cargo Mars drone not able to stay connected while transferring the pictures


I have written a Node.js based library to control the Parrot mini drones (link give below). Now in this library I have also incorporated the functionality to download the pictures we take while flying the mini drones. For the Rolling Spider drone, downloading works fine however for the Cargo Mars drone, while downloading the photo, the drone just gets disconnected for no reason.

I first send the ‘LIS’ command to get the list of all the pictures and then I pick one and send ‘GET’ command to download that picture. After the first set is transferred, once I send ‘MD5 OK’ command to tell the drone to send the next set, the drone just sends a bunch of bytes and after that it gets disconnected and stops sending any further bytes.

I tried sending the flat trim command along with the ‘MD5 OK’ command to keep the drone connected. That keeps the connection intact but then the drone sends the data improperly or not in order so I get an image which is distorted.

Can you please help me out here in keeping the drone connected until the download is finished or tell me how to download the picture in this case?