473,666 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing MIME Response - Splitting base64 String into an Array

4 New Member
Hi Everybody,

I've been working on this challenge for a while now without much luck. What I'm attempting to do is split a MIME byte response into its individual images. I am given the boundary to split on in the HTTP header but when I attempt the following code it doesnt work. If anybody has some suggestions on what I should attempt here I would greatly appreciate it.

Expand|Select|Wrap|Line Numbers
  1. 'boundary to split on
  2. Dim boundary as string = _
  3. "boundarystring"
  4.  
  5. 'read the HTTP response into byte array
  6. Dim byteArray() as Byte = memoryStream.ToArray()
  7.  
  8. 'convert the byte array into base64 string
  9. Dim base64String as String = _
  10. System.Convert.ToBase64String(byteArray, 0 byteArray.Length)
  11.  
  12. 'attempt to split base64 string by base64 version
  13. 'of boundary to retrieve individual photos
  14. Dim base64Array() as String = _
  15. base64String.Split(System.Convert.ToBase64String( _
  16. System.Convert.FromBase64String(boundary)))
  17.  
  18. 'then convert each base64 string back to image....
  19.  
Jun 16 '09 #1
5 4228
tlhintoq
3,525 Recognized Expert Specialist
but when I attempt the following code it doesnt work.
Can you be more detailed about what 'doesn't work' means? Exceptions... first image is good, rest are junk... none are good...
Jun 16 '09 #2
smclellan86
4 New Member
Sorry I suppose that might be helpful... The problem is when I attempt to split the base64 response with the base64 version of the boundary string it doesnt create an array. Its as though it cant locate the boundary within the response.

In the past I have tried converting the byte array into a string then splitting on the boundary as is. This actually works but when I attempt to convert each string element of the array back to a byte array and save it as an image it ends up corrupt.
Jun 16 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
Its as though it cant locate the boundary within the response.
Then the next step is to confirm your theory.
Before actually doing the split do a find for the boundary. You should get an index of it's location. If you get a -1 then it didn't find it
Jun 16 '09 #4
smclellan86
4 New Member
Ok unfortunately it does appear as though it can't locate the boundary; as I am receiving a response of -1.
Jun 17 '09 #5
smclellan86
4 New Member
Here's an example of the boundary/response in string and base64 formats, I have only included the header portion of the response:

String
Boundary:
--simple boundary

Response:

--simple boundary
Content-ID:2923871
Object-ID:1
Content-Description:
Content-Type:image/jpeg

-------------------------------------------------------------------

Base64
Boundary:
c2ltcGxlIGJvdW5 kYXJ5AA==

Response:
DQotLXNpbXBsZSB ib3VuZGFyeQ0KQ2 9udGVudC1JRDoyO TIzODcxDQpPYmpl Y3QtSUQ6MQ0KQ29 udGVudC1EZXNjcm lwdGlvbjoNCkNvb nRlbnQtVHlwZTpp bWFnZS9qcGVnDQ= =
------------------------------------------------------------------
Jun 17 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3225
by: Magnus | last post by:
Hi, I'm programatically posting an image using multipart/form-data. It sends to the server OK, but when I try to view it in the browser, it is still in the base64 string I sent it as: /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUG etc.... I've been through the form I built over and over: string PostData = ""; PostData += "-----------------------------7d41fb3081216"; PostData += "\r"; PostData += "\n";
2
20681
by: Dmitri Shvetsov | last post by:
Hi All, Does somebody know what's the length's ratio in we convert byte to base64 string? Is it a constant ratio or it can be different from case to case? For example if I convert a byte array of 20 bytes length can I expect that I get the base64 string with the same length every time when I do that? And what will be the maximum length of this string? What's the schema is taken for this conversion? If we use UUENCODE or something else...
4
2012
by: JeffM | last post by:
Quick C# question: I have comma delimited values in a string array that I want to pass to seperate variables. Any tips on splitting the array? Thanks in advance! JM
5
4832
by: AC [MVP MCMS] | last post by:
Any pointers on how to (1) read a Base64 encoded string from a text file and (2) write it to a binary file? I have a ton of files that are being generated from a legacy system. Each file contains a (1) content type one one line, a (2) filename, and (3) the encoding type (seems to always be Base64, followed by the encoded string. A process will be to read the content type and filename, then create a new binary file and write out the...
4
36141
by: Kliot | last post by:
I have a string that is a base64 graphic that I need to convert to a file, can someone give me some pointers on how to do this? Thanks
7
7915
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and image are perfect before submission. This involves converting any uploaded image to a Base64 String and holding that in a hidden form field until either the post gets submitted to the database or the image gets replaced with another one. I...
5
4949
by: Rasmus | last post by:
In a asp.net site i need to make a url link like this: http://server.com/test.aspx?base64=c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc= I've used the Convert.ToBase64String() to make the querystring parameter But as you can see the second char is a "+". When receiving the parameter...
2
1481
by: CharChabil | last post by:
Using Vb.net 2005, I want to read each part in this string in an array (splitting the string) ----------- A1/EXT "BK82 LB73 21233" 105 061018 1804 ----------- That Code that i used is as follow: Dim s As String, h As String Dim delim(1) As Char delim(0) = "/"
3
1597
by: Morten71 | last post by:
I have a strange problem. I have a local string() var I populate this way: clmns() As String = {"InvoiceNo", "InvoiceDate"} When I call: Array.IndexOf(clmns,"InvoiceDate") I get 0 (zero) as expected. If I fetch the values from the web.config this way: clmns() As String =
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.