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 converted base64 string.
Ideas?
--
-AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp 5 4852
How 'bout System.Convert. FromBase64Strin g ()
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"AC [MVP MCMS]" <sw*********@gm ail.com> wrote in message
news:9c******** *************** ***@msnews.micr osoft.com... 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 converted base64 string.
Ideas?
-- -AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp
Hello James,
Thanks... I guess I should have been more specific. I have that part, converting
the string to a byte array. But for images, I've noticed that there's a
header at the start of the file (appears to be just plain text, but not sure)...
for example a gif has GIF[version] at the start of the file.
I've tried writing out "GIF89a" at the start and then the byte array, but
that didn't work. Then I tried writing the GIF89a to a separate byte array,
write that out and then write the data stream byte array... but that didn't
work. I've seen some examples in this NNTP about using the BinaryWriter,
and comments by Jon Skeet how that's not necessary, but having a hard time
finding a single example of how to write this out on your own.
I'm not only interested in writing out GIF's, but also BMPs, JPEG, PNGs,
ZIPs, DOCs, XLSs, etc...
Ideas?
--
-AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp How 'bout System.Convert. FromBase64Strin g ()
Home: www.noveltheory.com Work: www.njtheater.com Blog: www.honestillusion.com Day Job: www.partsearch.com "AC [MVP MCMS]" <sw*********@gm ail.com> wrote in message news:9c******** *************** ***@msnews.micr osoft.com...
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 converted base64 string.
Ideas?
-- -AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp
Create a MemoryStream from the byte[]. Use the FromStream() and Save()
methods of System.Drawing. Image.
AC [MVP MCMS] wrote: Hello James,
Thanks... I guess I should have been more specific. I have that part, converting the string to a byte array. But for images, I've noticed that there's a header at the start of the file (appears to be just plain text, but not sure)... for example a gif has GIF[version] at the start of the file. I've tried writing out "GIF89a" at the start and then the byte array, but that didn't work. Then I tried writing the GIF89a to a separate byte array, write that out and then write the data stream byte array... but that didn't work. I've seen some examples in this NNTP about using the BinaryWriter, and comments by Jon Skeet how that's not necessary, but having a hard time finding a single example of how to write this out on your own.
I'm not only interested in writing out GIF's, but also BMPs, JPEG, PNGs, ZIPs, DOCs, XLSs, etc...
Ideas?
How 'bout System.Convert. FromBase64Strin g ()
Home: www.noveltheory.com Work: www.njtheater.com Blog: www.honestillusion.com Day Job: www.partsearch.com "AC [MVP MCMS]" <sw*********@gm ail.com> wrote in message news:9c******** *************** ***@msnews.micr osoft.com...
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 converted base64 string.
Ideas?
-- -AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp
--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Hello James,
This will work for images... but will it work for other content types (ZIP,
DOC, XLS)?
--
-AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp Create a MemoryStream from the byte[]. Use the FromStream() and Save() methods of System.Drawing. Image.
AC [MVP MCMS] wrote:
Hello James,
Thanks... I guess I should have been more specific. I have that part, converting the string to a byte array. But for images, I've noticed that there's a header at the start of the file (appears to be just plain text, but not sure)... for example a gif has GIF[version] at the start of the file. I've tried writing out "GIF89a" at the start and then the byte array, but that didn't work. Then I tried writing the GIF89a to a separate byte array, write that out and then write the data stream byte array... but that didn't work. I've seen some examples in this NNTP about using the BinaryWriter, and comments by Jon Skeet how that's not necessary, but having a hard time finding a single example of how to write this out on your own. I'm not only interested in writing out GIF's, but also BMPs, JPEG, PNGs, ZIPs, DOCs, XLSs, etc...
Ideas?
How 'bout System.Convert. FromBase64Strin g ()
Home: www.noveltheory.com Work: www.njtheater.com Blog: www.honestillusion.com Day Job: www.partsearch.com "AC [MVP MCMS]" <sw*********@gm ail.com> wrote in message news:9c******** *************** ***@msnews.micr osoft.com...
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 converted base64 string.
Ideas?
-- -AC [MVP MCMS] http://www.andrewconnell.com http://www.andrewconnell.com/mvp
AC [MVP MCMS] wrote: This will work for images... but will it work for other content types (ZIP, DOC, XLS)?
What exactly are you starting with? If the Base64 is a binary image of
the file you want write, why are you bothering with conversions at all.
Just write out the bits, and give it the appropriate extension.
--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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";
|
by: Mr.Clean |
last post by:
I need to write a function to return an image that
has been base64 encoded into a string.
This is how it is done in PHP and I need to know
how I can do the same in javascript:
function img_65()
{
header("Content-type: image/png");
|
by: mike |
last post by:
Is there any way I can change the content type when I open a new window
other than opening a script in the open statement?
mywin =
window.open('','rpt','width=600,height=425,top=50,left=0,scrollbars=yes,toolbar=yes,resizable=yes,dependent=no');
mywin.document.write("Content-type:image/svg+xml");
In this example I would be changing the content type to svg.
|
by: Guoqi Zheng |
last post by:
Dear sir,
I need to decode base64 encoded email.
I used below function but it does not work correctly, especially when I need
to decode some Characters like Chinese,
Can some one point out what I did wrong here? Thanks.
|
by: xavier_bizoux |
last post by:
Hi,
I'm new to javascript and to AJAX and I get a strange behaviour. I wrote a code which works perfectly in IE but not in Firefox. Could you please have a look to the following site with FF and with IE?
users.skynet.be/aikidobinche/Nouveau/Frame.html
You should get in the top frame a random quote.
Thnak you for your help.
| |
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...
|
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...
|
by: John |
last post by:
i have the following code to open a URL address, but can you please
tell me how can I check the content type of the url response?
Thank you.
try:
req = Request(url, txdata, txheaders)
handle = urlopen(req)
except IOError, e:
print e
|
by: smclellan86 |
last post by:
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.
'boundary to split on
Dim boundary as string = _
"boundarystring"
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |