Final file missing when converting html to excel using On Premise (Docker approach)

Original Discussion: Link

Problem :

I am making below axios call for on Premise approach:

let data = new FormData();
        let randomStr = Math.random().toString(36).slice(2, 8);
        let outputFileName=`output-${randomStr}.xlsx`;
        let outputDatafolder = 'htmlToExcelFilesData';
        let outputFilePath = outputDatafolder + '/' + outputFileName;
        data.append('file', htmlStream);
        let accessToken = await getAsposeAccessToken();
let configuration = {
            method: 'put',
            url: config.getConfig('ASPOSE_BASE_URL') + '/v3.0/cells/convert?format=XLSX&outPath=' + outputFilePath + '&checkExcelRestriction=true&streamFormat=html',
            headers: {
                'accept': 'multipart/form-data',
                'authorization': 'Bearer '+ accessToken,
                'Content-Type': 'multipart/form-data',
                'x-aspose-client': 'Containerize.Swagger',
                ...data.getHeaders()
            },
            data: data
        }

I am getting below successful response:

{
  FileInfo: {
    Name: 'output-09ov32.xlsx',
    Size: 9255,
    Folder: 'htmlToExcelFilesData'
  },
  Code: 200,
  Status: 'OK'
}

But I am not able to find converted file in my azure storage account file share. I am not able to find it in my mounted folder in pod as well.

Please also note that I am already using aspose on Premise for conversion of excel to pdf and was getting converted files in azure file share. So ideally, this converted file should also be present in that file share right?

@rajatdpw,
Once again, I think carefully about the question you raised.
From your query parameters, the converted file should be stored in the folder of Aspose Cloud Default Storage, where you can find your output file.
If you still can’t find the file, we can take a different approach to this problem.

Remove the “outpath” of the query parameters, the response content by the convert API is a file stream, and you can write this file stream directly to your file.

Please refer to the following code:

 string url = BuildUrl("convert? Format=html");
 string bodyParam = null;
 Dictionary<string, string> headParams = null;
 Dictionary<string, object> formParams = new Dictionary<string, object>();
 Stream stream = ReadFromFile(Book1Xlsx);
 if (stream != null) formParams.Add("Book1.xlsx", ApiInvoker.ToFileInfo(stream, "File"));
 
 Stream response = ApiInvoker.InvokeApiAsync<Stream>(url, "PUT", bodyParam, headParams, formParams).Result;
 using (Stream outStream = File.OpenWrite(destFile))
 {
 	response.CopyTo(outStream);
 }

Hi @wangtao I tried above method using on premise. It seems to be working but I am not able to understand the response i am getting.

result.data looks something like this:

Edit=> typeof this data is string. Is there any way to get buffer data in response?

               ^�$�7���W���z����@�40�$���X����P!�J��@{$docProps/app.xml
 ��������������_K�0ſJ���v��f�"�������-�&!�+��ޤ��ɞ|;�O���R�>umփ����d����ޗ�z�ݑ̣еh���
                                                                                 �ɚ��3*�Y0о$D����t���X�Ic\'0�nOM�(	�F;�Hy~Kᄠk�g�lH������FF>��9���UR`xcF�r�^̋�<��sF'=� �N���hZ�g�6�����˼�
�Y��Cx��%�SBcȏk�uk=:�nܧ?�g���tw�Ւ�B���W#H\"V
[��F8�B\L�G�ě��/e�F��I��]Ag[�o�"�؃���tV�!J����oP!mh%u�$docProps/core.xml
 ������������m�[K�@��J��f�����|]g���셙�i���bA���9�1�f{�}��.�VU�Z Z�V��>��U�b�5}
�"�3ń$�Ȝ�5�VDR�5���2'B6����,�����t�o��;�Q�5b��J                                تYm7
                                               Q�H

                                                  2���4��몬�oV�<�[09WI�dLy���k��sI��-�a��vj#�_�����4�ʅ˦զ�P��
                                                                                                            =���� �B#�.*�����lZd �$�c�e�/�wh���`i���56�P�!QW�t{��$xl/media/image1.png
 %k�$��k�$��k�$��}y�7���N���m7z]��WX�DDYm�^������b�h�˪Q-��k��zgu�?�����̝�=g枙�<���������

                                                                                       �)XME

                                                                                            ���!"x����(<O%�ѣY~�?qS3���"����&��b�
VQ����G�ؼ7E�w�ڼ��K[v'��Rۑ��`%�<  U�B�
                                     �A���#C�lWFË�ev�-�`�!&agy��E$��|��(j)-k���Ό�;�uw�}���{נ�������x�mx6��z��0�����3���<�W��p"�
                                                                                                                               3�|�a��HU)=���щ]9�Q��^�~|F�cu���E��A���5�va�J>�{��
                                             �X��N�đ�^��(�ۑ���*z`z�P�>�s�	��J)DOH_��Β`��d�[G�*"k��$-���$�|?��/�s1�YI�xJ���7�FK���������dc������t����D��d�/���R�w2����"����]��$�a�����I�t�>��~?�6�	�@�C�Db��1[Q�#��'�Ho_�]�{�s0��:,�x��o��	�y�RpY�:﷢�ߚ��w5I>���Ewm4��`a<t$)�����rf!��$_PӨ6˜J�l���7�kR/T&W�g^Ƕv�4��F�j�WrKr�*�Bz��&$>�R�oBl�H�}p��Z`�`i��ܻ���ȸ�����<��Pv�E�Wb@Ό�S6�����!��
                                                      ���%�V�p!���|P���
h�s��4�Yb
�]��+�Q]��/(���d����z����Gw�
                            �T�S���Ǹ���̪�!�>wt{�T�t?��8�e��$xW%���R?�J=��<N?�\��gds?-�0o��?p� �"��[�֯����Aq:�`MOK�KΨI�ϛe�+O��G]_lmM��s�9D���2���,Z��

@rajatdpw ,

The response data is a stream buffer. You may deserialize an object from JSON string.

You may refer to Cells Cloud SDK for Node.

let result = await axios(configuration);
let buffer = Buffer.from(result.data, ‘binary’);
fs.writeFileSync(localPath, buffer);

The file that I get looks corrupted. I have attached with the message. Please let me know if you find any way to get the file correctly.
File link: https://docserqablobs.blob.core.windows.net/dtlp-file-storage-qa/targaryen/12345/testFile/test.xlsx?st=2023-10-17T04%3A26%3A44Z&se=2023-10-25T04%3A26%3A44Z&sp=r&spr=https&sv=2018-03-28&sr=b&sig=iITOd9yrHthtD3EyKVDalyWl%2BeDhwkYwAw80A04HhSE%3D

@rajatdpw ,

OK, I got the file. I will check it and reply.

@rajatdpw ,
I have reviewed the provided file, and it appears to have been generated by Aspose.Cells 23.1.1.
I would like to inquire about when and under what circumstances this file was created.

I am trying to convert an excel file from html file. So, I used the on premise approach. I get above response as I try to do it as discussed with said approach (without providing outPath). Docker image is aspose/cells-cloud:linux.23.1.1

@rajatdpw ,
I understand. I will set up a simulation of your runtime environment and conduct further testing. Additionally, have you had a chance to try the latest version of Aspose.Cells Cloud?

@rajatdpw,
By simulating your operating environment, I was able to reproduce the issue of file missing. I have now generated a new support ticket for this problem and will provide a fresh solution as soon as possible.

@rajatdpw ,

Please refer to the following code, which is functional for converted file output. Additionally, I will release an updated version of the Docker image file as soon as possible.

 const axios = require('axios');
 
 const FormData = require('form-data');
 const fs = require('fs');
 const { readFile } = require('fs/promises');
 const htmlStream = fs.createReadStream('ToxXlsx.html');
 
 async function convertHtmlToExcel() {
   console.log('Begin to convert Html to Excel.');
   let data = new FormData();
   let randomStr = Math.random().toString(36).slice(2, 8);
   let outputFileName = `output-${randomStr}.xlsx`;
   let outputDatafolder = 'htmlToExcelFilesData';
   let outputFilePath = outputDatafolder + '/' + outputFileName;
   data.append('file', htmlStream);
   let configuration = {
     method: 'put',
     url: 'http://localhost:47901/v3.0/cells/convert?format=XLSX&checkExcelRestriction=true&streamFormat=html',
     responseType : 'stream',
     headers: {
       'accept': 'application/json',
       'Content-Type': 'application/json',      
       ...data.getHeaders()
     },
     data: data
   };
   try {
     const response = await axios(configuration);
     response.data.pipe(fs.createWriteStream('ConvertHtml.xlsx'));
   } catch (error) {
     console.error('Error:', error.message);
   }
   console.log('End.');
 }
 convertHtmlToExcel();

Hi @wangtao . Thank you so much for the above code. I am able to get the file now. Really appreciate your support.

@rajatdpw ,

I updated the fixed version. Please try to use the latest image (aspose/cells-cloud:linux.23.10.1).