On permise Aspose.cells issue: service and pods are up but not sure but throws error when api is hit

I am using docker image for aspose.cells to set up on premise aspose.cells cloud. Now image is up and running, and I can see swagger ui when hit the /index.html endpoint…

but if i try to use any api, for example: conversion api to save excel file as pdf, image.png (201.6 KB)

here i am not able to execute the api. moreover not able to understand that the workbook name
mentioned, like where should the file be present in case of onpremise…does that need to be mounted?

Also after mounting, i am executing following lines of code to hit the api:

let configuration = {
                method: 'post',
                url: baseUrl + '/v3.0/cells/' + inputFileName + '/SaveAs?newfilename=' + outputFilePath + '&isAutoFitRows=true&isAutoFitColumns=true&folder=' + inputDatafolder +'&checkExcelRestriction=false',
                headers: {
                    'accept': 'application/json',
                    'Content-Type': 'application/json',
                },
                data: 'data'
            }
            await axios(configuration)
                .then(function (response) {
                    if(response.status === 200) {
                        logger.info(`File converted successfully to pdf.`);
                    }
                    else {
                        logger.error(`Error while converting file to pdf. Response Status Code: ${response.status}`)
                    }
                                    })
                .catch(function (error) {
                    throw error;
                });

Is the above method correct for hitting this api? i am getting 400 error that object instance in not defined.

Response: MicrosoftTeams-image (3).png (270.0 KB)

PS: I just need to confirm is there any thing wrong in above code if i am hitting the api through axios.

@rajatdpw,

Please refer to the following curl call the SaveAs API:
curl -X POST “http://192.168.3.38:47901/v3.0/cells/Book1.xlsx/SaveAs?newfilename=Book1xlsx.pdf&isAutoFitRows=false&isAutoFitColumns=false&checkExcelRestriction=true” -H “accept: application/json” -H “Content-Type: application/json” -d “{Format:PDF}”

Not able to import it, getting this:

Error while importing Curl: Only the URL can be provided without an option preceding it.All other inputs must be specified via options.

Can u share curl (bash). It would be a great help. Thanks a lot in advance

Also can u tell where is Book1.xlsx file getting stored in this on permise case. This is also a big confusion for me.

@rajatdpw,

Please refer to the following steps:

  1. create a linuxStorageResource.json in the folder(c:\data) and content is as follows:

{
“Local”: [
{
“Name”: “First Storage”,
“RootFolder”: “/data”
}
]
}

  1. refer to the followwing command and re-run docker.

docker run -d -v c:/data:/data -p 8081:5000 -e LicensePublicKey=LicensePublicKeyValue -e LicensePrivateKey=LicensePrivateKeyValue -e storagesCredentialsFilePath=/data/linuxStorageResource.json --name asposecellscloud aspose/cells-cloud:linux.23.1.0

  1. Upload the file and check the upload result.
  2. Refer to the following picture, and try to test the SaveAs API on swagger.

Hi @wangtao. First of all, thank you so much for brief explanation. i still have some doubts:

  1. I am using mac and using docker image for linux, for that what should be the folder?
  2. Books1.xlsx is stored where? in local or storage account? if local then which folder(if mac user)? 3. like you mentioned upload the file, can u elaborate how and where to upload in case of local setup?

response for a file:
image.jpg (96.2 KB)

@rajatdpw,

The RootFolder described in linuxStorageResource.json is a directory in Linux.
Book1.xlsx is stored in the corresponding Mac directory, which is mapped to the Linux directory in the Docker container.

Hi @wangtao. I followed your steps.

Curl:
curl -X POST “http://localhost:8086/v3.0/cells/a.xlsx/SaveAs?newfilename=out.pdf&isAutoFitRows=false&isAutoFitColumns=false&folder=data&checkExcelRestriction=true” -H “accept: application/json” -H “Content-Type: application/json” -d “{Format:PDF}”

Docker Comand:

docker run -d -v ~/Downloads:/data -e"LicensePublicKey=LicensePublicKeyValue" -e “LicensePrivateKey=LicensePrivateKeyValue” -e storagesCredentialsFilePath=~/Downloads/linuxStorageResource.json --name asposecellscloud-3 --expose 8086 -p 8086:5000 aspose/cells-cloud:linux.23.1.0

Also tried with absolute path:

docker run -d -v /Users/rajatbhardwaj/Downloads:/data -e"LicensePublicKey=LicensePublicKeyValue" -e “LicensePrivateKey=LicensePrivateKeyValue” -e storagesCredentialsFilePath=/Users/rajatbhardwaj/Downloads/linuxStorageResource.json --name asposecellscloud-3 --expose 8086 -p 8086:5000 aspose/cells-cloud:linux.23.1.0

Same below response in both of the above cases

Response:
MicrosoftTeams-image (4).png (408.9 KB)

Please Note: I have created a file name a.xlsx in Downloads folder in my mac. Please let me know if I am missing something or making some mistake in execution.

Really thankful for your help so far

@rajatdpw,

I checked your docker command and found the value of storagesCredentialsFilePath is wrong.

Also, we fixed a few bugs with the swagger UI. Try aspose/cells-cloud:linux.23.1.1 and refer to the following commands:

docker pull aspose/cells-cloud:linux.23.1.1
docker run -d -v /Users/rajatbhardwaj/Downloads:/data -p 8086:5000 -e LicensePublicKey=LicensePublicKeyValue -e LicensePrivateKey=LicensePrivateKeyValue -e storagesCredentialsFilePath=./storageResource.json --name asposecellscloud aspose/cells-cloud:linux.23.1.1

Please copy an Excel file to your mac download folder.
Try saving as API on swagger-ui.

@rajatdpw,

We fixed the upload file on swagger UI.
Try uploading file API with swagger UI.
The uploaded files can be found in the mac folder(/Users/rajatbhardwaj/Downloads).

Hi @wangtao. Thanks a lot for your help, i am able to run apis now with above steps.

There is one thing I want to ask though: is there a limit as in how much records/sheets excel file can be converted? because the api is working fine on files with small number of records but with a large file it is throwing this error

2023-02-03 11:55:44 pid: 19 error [server.js]: “[50090] Aspose - Internal Server Error: Error: Request failed with status code 400\n at createError (/usr/src/app/backend/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/usr/src/app/backend/node_modules/axios/lib/core/settle.js:18:12)\n at IncomingMessage.handleStreamEnd (/usr/src/app/backend/node_modules/axios/lib/adapters/http.js:202:11)\n at IncomingMessage.emit (events.js:205:15)\n at IncomingMessage.EventEmitter.emit (domain.js:471:20)\n at LegacyContextManager.runInContext (/usr/src/app/backend/node_modules/newrelic/lib/context-manager/legacy-context-manager.js:59:23)\n at IncomingMessage.wrapped (/usr/src/app/backend/node_modules/newrelic/lib/transaction/tracer/index.js:204:37)\n at IncomingMessage.wrappedResponseEmit (/usr/src/app/backend/node_modules/newrelic/lib/instrumentation/core/http-outbound.js:205:24)\n at endReadableNT (_stream_readable.js:1137:12)\n at /usr/src/app/backend/node_modules/newrelic/lib/shim/shim.js:1313:22\n at LegacyContextManager.runInContext (/usr/src/app/backend/node_modules/newrelic/lib/context-manager/legacy-context-manager.js:59:23)\n at Shim.applySegment (/usr/src/app/backend/node_modules/newrelic/lib/shim/shim.js:1303:25)\n at wrapper (/usr/src/app/backend/node_modules/newrelic/lib/shim/shim.js:1904:17)\n at processTicksAndRejections (internal/process/task_queues.js:84:9)”

Please Note: I am using on premise for conversion. Do let me know if some configuration is to be set in order to do that.

Input File: inputFile.xlsx - Google Sheets

@rajatdpw,

First, please check how much memory Docker allocates to the container. And we will test your provided Excel file ASAP.

By the way, The Cells Cloud services set the maximum allowed size of any request body in bytes is 100000000000000 bytes.

@rajatdpw,

I tested the API of SaveAs with Windows/Liunx container on Windows 11. The test passed.
Could you detail a description of how to create the container and the container stat?

Hi team. Seems like it wasn’t api issue, request was getting timeout. we increase serverresponsetimeout. Working fine now. Thanks a lot for your support.

@rajatdpw,

Good to know that your issue is resolved. Feel free to contact us any time if you have further comments or questions.

1 Like

Hi @wangtao. Do you have any time range so as to how much time it takes to convert excel to pdf. For example a file with total of 13k records(100 records in 130 sheets), how much time ideally it should take? Also similar thing if can be found for 15k,20k, 30k records as well.

Also the api seems to be inconsistent at times as sometime it creates file within 3 minutes, some time more and some time gives socket hangup error. so need some clarity on this expected time range

@rajatdpw,
We will further analyze the issue you mentioned and give you a detailed reply.

@rajatdpw,

I think the performance of the machine determines how fast the API runs.
I tested it in two windows environments
Environment 1:
OSType: Linux
Architecture: x86_64
CPUs: 20
Total Memory: 31.2GiB
Call API: Save As

Converting inputFile.xlsx to pdf takes less than fifty seconds.

Environment 2:
OSType: Linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.908GiB
Call API: Save As

Converting inputFile.xlsx to pdf takes more than 300 seconds.