0

I am facing a problem while returning a string. I have a java code and which will convert to image. I am able to convert the image in the backend using this Java code but i need to do this in frontend.

String responseString="ë!!ëh$þë.ë
 (-0mÓæEÈRjqY-ÖÉr-Êjêתl-d@i¶`饭­mÛzàMÄínþÎmÝÞmÞ®ßþmàná&­&nÓ:mãêëã^írLî6ví^î³fî&r®Ù~®Â®ÛÜBìéöfêâ­Þ:@ëö-à
¸o¿ú¨üÒ¯ýf"æïðò/þo謭 { 0+0;0_ÆÌTðø6øïktðS§0 K®  o#
$ð[@?0t¬È'YpÓño0± íò8ø¥¥ÄFðd¾ÞFBùÁ¸éû&k%Jb<±hÁåJ?¤?| y®0Æp Ó0ãÀlÀÀXAðÿÀÿìðS°ñz±÷T? "×<óq   ÿ1ò
ærhíû-×ïMèr®pTdEþkÎÀµÎ´ó #< Ø     ¬´A=?³?às>»Xó@ôA«©dRøCCoÀC8ßDEFórlôØÊGÓáHÿÁÚ4tJ¯4 ´ôKCóO3XдM.Atâêô¤*4C;4Dï.B5
_ô×f´(õæ2µâSGµ$O5J«4K»´3k5rMsdXçôt
´Ëô@@
0VPÀûûû<ü     æü´öÀf(æoAFVüÅ?@
Dhp!C¹f¼Ø5"þÇ%ymÊ-cÂIÓfN<}JÔ(R¥LBJÕêÕ¬
8ÚÂ
-Ë&û"øðxáÍ`r¨&2Ðá ¾xüI-bP`þ£ôJÈà@A&î è øÀèp»2ã*òAÃÉ:ü0  I4 Ud aÆfÀQG}L
:î!a  O¸?þ±pD.ü;Ç¢¢¯p7à+xArnA!HèòÀý#X¼ hV"



String fileName = "one.gif";
 String fileLocation = new File("src\\main\\resources\\static\\img").getAbsolutePath() + "\\" + fileName;
      FileOutputStream fos = new FileOutputStream(fileLocation);
 fos.write(responseString.getBytes("ISO-8859-1"));
   fos.flush();
   fos.close();

I want to return this responseString and use in angularJs. How to return form Restcontroller and use in Angular/HTML? When I return directly responseString I am getting ERRORError: [$http:baddata] http://errors.angularjs.org/1.6.4/$http/baddata? also.

0

1 Answer 1

0

From the AngularJS docs: "To resolve this error, make sure you pass valid JSON data to transformResponse or use an appropriate Content-Type header for non-JSON data."

Set the appropriate content-type header on the server side.

You should choose the appropriate MIME type from this list: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.