email - Http Response Contains MIME stream.. which has binary Images seperated by Boundary String.. need to get those Images and save using c# -


when make http request server responses mime response stream has 2 or more images in binary data separated boundary string need extract images , save them individually database

stream looks this...

header has

rets-version: rets/1.0  mime-version: 1.0  content-type: multipart/parallel;  boundary="simple boundary" 

http resoinsestream has

--simple boundary

content-type: image/jpeg  content-id: 123456  object-id: 1  <binary data>(image1) 

--simple boundary

content-type: image/jpeg  content-id: 123457  object-id: 1  <binary data>(image2) 

--simple boundary --

i need extract image1 , image2 , save in database binary image.

if use mimekit library, can easily:

static mimeentity parsehttpwebresponse (httpwebresponse response) {     var contenttype = contenttype.parse (response.contenttype);      return mimeentity.parse (contenttype, response.getresponsestream ()); }  static void saveallimages (httpwebresponse response) {     var entity = parsehttpwebresponse (response);     var multipart = entity multipart;      if (multipart != null) {         foreach (var image in multipart.oftype<mimepart> ()) {             using (var memory = new memorystream ()) {                 image.contentobject.decodeto (memory);                  var blob = memory.toarray ();                  // save database             }         }     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -