0

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?

Community
  • 1
  • 1
Kanak Sony
  • 1,570
  • 1
  • 21
  • 37
  • Did you try what has been suggested on the link you provided? – Merlevede Feb 21 '14 at 19:27
  • @Merlevede I have tried answer provided by haraldK, but I am getting a corrupted image. – Kanak Sony Mar 04 '14 at 11:15
  • @KanakSony: Can you post the code you have so far? If you receive a JPEG in your PUT, you can just write the data (after the header) to disk, and you'll have a JPEG file. And as I said in the other answer, please use an HTTP container to do this, it *will* save you hours of debugging (unless you happen know all the dirty details of the HTTP spec by heart). – Harald K Mar 04 '14 at 11:34
  • @haraldK Sure.. I am creating a new question and will send u the link in few mins.. – Kanak Sony Mar 04 '14 at 11:38

1 Answers1

0

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?

Javier
  • 2,752
  • 15
  • 30