Hey guys, if i have data that looks this: ```PKO�....
# suitescript
e
Hey guys, if i have data that looks this:
Copy code
PKO�.Z����[Content_Types].xml��MO�0����(�P��a�Z5������ݫkO��dO����4BH��)�y���Q�gOFg�r�.N�I��N*���?��g�E�Vr�,��bq6;���bFb�E�����c�E�%�n�UD��^D�M�>����n~H�ھ�QD]X����cf֛��+�l�WbYՂ���X�)�_�� ��!xT�Yl���#@e&�6fV >+��[)���A�BD_*mH�����t(Wu}-�ooFL�5�����lw��?�tH`�@�pS�Nd18�Iq�CI�ώ�������Ph[��.�COS^x$�ͼ�8g�<�Ѹ�G�-$#�Wz�fuރQp��0���Z���}��[6�PKO�.Z��Si�docProps/core.xml���N�0E�|E�MV��EI*�JH�ع�45Ml˞6���mZ�+v�;��p>�7��c������d�Y��b���E*9���������&g:c���Q ��I�1]Lֈ:#IJ54Ԇ�!��R���BSMنV@�(�# �)遁��#�����������aL�^�ث �r�lv�ZO���[1۶ �t���c�1~Z ��G�`R�e(�2�v�3@Q�Rw�V2���srq��v]�������@���[v�oĥ������-s%�?td�3����8'�a~�ݡ�w=g� �����i1��I�A�I�H�,�͢��G��+�7��g^)�wC����PKO�.Z����ldocProps/app.xml�T�n�0��+]t�iAQ���A�C�������"J��1�~}��9�/��;�;�����Af�NhU����Pq� ��������"s��V�]q_�ʭ�- t�WP��{"�b��psO+�t�@޴{��Np|��e@E�v����P��ޘQ0O����h�y��=5G���Y�� Fa�3�y�i(وFM 1`���hj{t��d��gm[<�#@�,p���� �c��@~��Fp���(���� S��W��퐿XAǠ95�C(���#�jao���X��q�����;�K��;B��D*�CZ������o��78��
and I need to turn it into a base 64 docx file,
Copy code
file.create({
	       name: `xyz.docx`,
	       fileType: file.Type.WORD,
           encoding: file.Encoding.BASE_64,
           contents: x,
			});
what am i missing? Thanks!
b
its too late, your contents was incorrectly encoded into utf-8
all these
are encoding errors
e
this is my contents:
Copy code
PKO�.Z����[Content_Types].xml��MO�0����(�P��a�Z5������ݫkO��dO����4BH��)�y���Q�gOFg�r�.N�I��N*���?��g�E�Vr�,��bq6;���bFb�E�����c�E�%�n�UD��^D�M�>����n~H�ھ�QD]X����cf֛��+�l�WbYՂ���X�)�_�� ��!xT�Yl���#@e&�6fV >+��[)���A�BD_*mH�����t(Wu}-�ooFL�5�����lw��?�tH`�@�pS�Nd18�Iq�CI�ώ�������Ph[��.�COS^x$�ͼ�8g�<�Ѹ�G�-$#�Wz�fuރQp��0���Z���}��[6�PKO�.Z��Si�docProps/core.xml���N�0E�|E�MV��EI*�JH�ع�45Ml˞6���mZ�+v�;��p>�7��c������d�Y��b���E*9���������&g:c���Q ��I�1]Lֈ:#IJ54Ԇ�!��R���BSMنV@�(�# �)遁��#�����������aL�^�ث �r�lv�ZO���[1۶ �t���c�1~Z ��G�`R�e(�2�v�3@Q�Rw�V2���srq��v]�������@���[v�oĥ������-s%�?td�3����8'�a~�ݡ�w=g� �����i1��I�A�I�H�,�͢��G��+�7��g^)�wC����PKO�.Z����ldocProps/app.xml�T�n�0��+]t�iAQ���A�C�������"J��1�~}��9�/��;�;�����Af�NhU����Pq� ��������"s��V�]q_�ʭ�- t�WP��{"�b��psO+�t�@޴{��Np|��e@E�v����P��ޘQ0O����h�y��=5G���Y�� Fa�3�y�i(وFM 1`���hj{t��d��gm[<�#@�,p���� �c��@~��Fp���(���� S��W��퐿XAǠ95�C(���#�jao���X��q�����;�K��;B��D*�CZ������o��78��
b
those are not your contents
that is the result of your binary file being encoded in utf-8
your file isnt utf-8, thus all the errors
e
i got it from an api that's sends docx file content
i need to translate that into base_64
b
that sounds like you got it from N/https
e
correct
b
and when it receives a response in binary, it either encodes the binary into utf-8 or base 64
e
do i need 'Content-Type'?
b
with it choosing utf-8 if the content type of the response indicates that it is plain text
or if it doesnt recognize the content type
if it the content type is one of the ones that it thinks is binary, it will encode the binary as base 64
usually you dont control the content type of the response, thats on the server sending the response to you
e
so how would i get the contents in base 64 'Content-Type': 'text/plain', 'Accept-Charset': 'utf-8', ?
b
that content type is extra wrong
if you send that content type in a request to a server, it means you want a response back in plain text, specifically utf-8
e
what would for base 64
b
your word document is not plaintext
e
they said that they gave me a url to download a file. When i call that url, i get that content, but file.create won't allow that
b
tell them that you need a different content type in the response
i personally would suggest
Copy code
application/msword
but there is a wide range of content types that netsuite considers binary