You need to sign in to do that
Don't have an account?
viki
Saving Document as image from Binary stream.
Hi All,
I am getting binary stream of an image from webservice call.I need to save it to Document (or any other object please suggest), so that i can show it in my page.Please provide me the way to show it in Visualforce page also.
Below is the mentioned Binary Stream for .PNG image.
�PNG IHDRv�� � pHYs���+ OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q,� ��!���������{�kּ������>�����H3Q5��B�������.@� $p�d!s�#�~<<+"��x��M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'�����{[�!�� e�Dh;��V�EX0fK�9�-0IWfH�����0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^�u��f�@����W�p�~<<E���������J�B[a�W}�g�_�W�l�~<�����$�2]�G�����L�ϒ �b��G����"�Ib�X*�Qq�D���2�"�B�)�%��d��,�>�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,�����`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2��G1���Q=��C��7�F��dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"����V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w
First you need to convert it in Blob type then insert in document. Suppose you are getting binary stream in variable named myPic :
Blob theBody=Blob.valueOf(myPic);
Document d=new Document();
d.folderId=’….’; // give the folderId in which you want to upload your data
d.body=theBody;
d.name=’testname’;
insert d;
For displaying data in page define the property in controller,
url='/servlet/servlet.FileDownload?file=’+d.id;
and show in page using this property.