aspose-slides-cloud / aspose-slides-cloud-nodejs

JavaScript library for communicating with the Aspose.Slides Cloud API
MIT License
1 stars 1 forks source link

When running `savePresentation` I get an error "Cannot access a closed Stream", and the file is copied successfully. #4

Open itsikbelson-spotlight opened 8 months ago

itsikbelson-spotlight commented 8 months ago

I'm using the following code to convert pptx to pdf (using integration with cloud storage).

   const slidesApi = new SlidesApi(
      '<APP_ID>'
      '<SECRET>'
   );

   const asposeStorage = '<STORAGE_NAME>';

   await slidesApi.savePresentation(
       basename,
       ExportFormat.Pdf,
       outPath,
       undefined,
       undefined,
       folder,
       asposeStorage
    );

The file conversion suceeds and is saved in the outPath. However, the savePresentation call returns error:

{ message: 'Cannot access a closed Stream.', code: 500 }

I've tried to call the HTTP API directly using postman, and got a similar response:

{
    "requestId": "684c5ea3-2f99-4994-81cb-18c9c53f432e",
    "error": {
        "code": "internalError",
        "message": "Cannot access a closed Stream.",
        "description": "Operation Failed. Internal error.",
        "dateTime": "2024-01-14T10:57:36.4471327Z"
    }
}

How can it be resolved?

andreypotapovaspose commented 8 months ago

@itsikbelson-spotlight, Unfortunately, I was unable to reproduce the error you described. The savePresentation method works fine on our end. Could you please share the presentation file you used?

itsikbelson-spotlight commented 8 months ago

Sure. Attached. Note that it happened with every other pptx I've tried. itsik-test.pptx

andreypotapovaspose commented 8 months ago

@itsikbelson-spotlight, I am still unable to reproduce the problem you are experiencing. I used the following code example:

slidesApi.savePresentation("itsik-test.pptx", "Pdf", "output.pdf").then(() => {
})
.catch(error => {
    console.error(error.message);
});

Could you please indicate the version of Node.js you are using?

itsikbelson-spotlight commented 8 months ago

Sure. We're using node v18.

andreypotapovaspose commented 8 months ago

@itsikbelson-spotlight, I checked the problem with Node.js 18. The savePresentation method works fine.

Note that it happened with every other pptx I've tried.

It looks like the issue is not related to Aspose.Slides for Node.js. You should check your environment.

itsikbelson-spotlight commented 8 months ago

Thanks @andreypotapovaspose, but it also happened to me when using direct requests (using PostMan). In fact, the request id in the comment is the one taken with postman.

andreypotapovaspose commented 8 months ago

@itsikbelson-spotlight, Thank you for the details. I am working on the issue and will get back to you soon.

andreypotapovaspose commented 8 months ago

@itsikbelson-spotlight, Unfortunately, I was still unable to reproduce the error using Postman. We need more details to investigate the case.

itsikbelson-spotlight commented 8 months ago

LMK what more info is needed. In the meantime, that's the curl request I ran in order to reproduce: To get the token:

curl --location 'https://api.aspose.cloud/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<CLIENT_ID>' \
--data-urlencode 'client_secret=<CLIENT_SECRET'

To do the conversion (this one returns 411):

curl -w '%{http_code}\n' --location --request PUT 'https://api.aspose.cloud/v3.0/slides/itsik-test.pptx/Pdf?outPath=dacHYDUidgPpUSWMOPnadMXZfYi1%2Fdoc%2Fitsik-test.pdf&folder=dacHYDUidgPpUSWMOPnadMXZfYi1%2Fdoc%2Fsources&storage=remote-assets-dev' \
--header 'x-aspose-client: nodejs sdk v23.11.0' \
--header 'Authorization: Bearer <ACCESS_TOKEN>'
andreypotapovaspose commented 8 months ago

@andreypotapovaspose, Please try the simplest request example first and check your results. I saved the "itsik-test.pptx" file to the root of the default storage and performed the request. It works fine. screenshot I hope this will help you to isolate the problem.

itsikbelson-spotlight commented 8 months ago

ok. thanks