Unexpected End of Stream Occurred when Converting PPTX to JPG

Im trying to convert a pptx file to jpg and reduce the writes to disk I create. When I send the buffer as a readable stream I am getting this error:

Error Code 500: Unexpected end of Stream, the content may have already been read by another component.

Code:

  const streamBuffer = Readable.from(req.file.buffer);

  slidesApi.convert(streamBuffer, api.ExportFormat.Png, null, null, null, null, size).then((response) => {
    console.log(response);
    try {

      // shell.rm('-rf', 'public/slides/*');

      // var zip = new AdmZip(response.body);

      // zip.extractAllTo(/*target path*/ "public/slides", /*overwrite*/ true);

    } catch (err) {
      console.error(err);
    }
  }).catch((error) => {
    console.log(`Error Code ${error.code }: ${error.message}`);
    res.send("Error Code " + error.code + ": " + error.message);
  });

@albertsonblake,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides Cloud SDK for Node.js if it is possible. If the issue persists, please share the following data and information:

  • presentation file
  • OS version where the code was executed
  • Cloud SDK you used

presentation file pptx

Im running the latest version on this npm repo asposeslidescloud - npm

code was executed on macOS 12.3.1

@albertsonblake,
Thank you for the additional information. We will need some time to check the issue. We will reply to you as soon as possible.

1 Like

@albertsonblake,
I’ve reproduced the problem with Readable stream when using the Convert method and added a ticket with ID SLIDESCLOUD-1481 to our issue tracking system. We apologize for any inconvenience. Our development team will investigate this case. You will be notified when the issue is resolved.

@albertsonblake,
Our developers have investigated the case. You can avoid the error by using the createReadStream method as shown below:

const fs = require("fs")

const streamBuffer = fs.createReadStream(req.file.buffer)

Is this solution right for you?