Conversion of raw JPEG bytes received from HTTP PUT in Android

走远了吗. 提交于 2019-12-11 19:48:15

问题


I am receiving an HTTP PUT in this format -

PUT /photo HTTP/1.1
X-Apple-AssetKey: F92F9B91-954E-4D63-BB9A-EEC771ADE6E8
X-Apple-Transition: Dissolve
Content-Length: 456850
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c

<HERE COMES THE JPEG DATA>

like -

 [ PUT /photo HTTP/1.1 ]
 [ X-Apple-AssetAction: cacheOnly ]
 [ X-Apple-AssetKey: 00000000-0000-0000-0000-000000000068]
 [ Content-Length: 462848 ]
 [ User-Agent: MediaControl/1.0]
 [ X-Apple-Session-ID: 16d9a403-82ac-48ee-8402-5315fc018f9d ]
 [ ????????? ]  
 [  ] 
 [  ]
 [ ]
 [???? ? ? "?? ?? ????? ????????????????  ]
 [ ?? ???? } ?? !1A Qa "q 2??? #B?? R??$3br? ]
 [ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz????????????????????????????????????????????????????????????????????????? ?? ????????????   

so on....

I have the same scenario - Http PUT Request to jpeg. I have wrapped data in between " [ ] " brackets here.

How can I write this JPEG Data to JPEG Image?


回答1:


From the response you reference, after finding the end of the headers:

  1. Open an output stream to a file.
  2. Continue iterating over the input stream
  3. Write every block you read into the output stream.

Do you need pseudo-code?



来源:https://stackoverflow.com/questions/21943066/conversion-of-raw-jpeg-bytes-received-from-http-put-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!