473,466 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Base64 strange problem

I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.

The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.

May 14 '07 #1
4 3820
VK
On May 14, 9:10 pm, Tamir Weiss <tamir.we...@gmail.comwrote:
I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.

The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.
What library are you using? Be aware that IE does not let you to read
binary files no matter what.

May 14 '07 #2
In comp.lang.javascript message <11*********************@l77g2000hsb.goo
glegroups.com>, Mon, 14 May 2007 10:10:44, Tamir Weiss
<ta*********@gmail.composted:
>I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.

The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.
It is clear what your problem is; it is that you have done something
wrong.

A better description of what code you use might render possible a more
specific response. However, as you asked no question, you may not be
expecting any answer.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 14 '07 #3
On May 14, 10:08 pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <1179162644.877937.92...@l77g2000hsb.goo
glegroups.com>, Mon, 14 May 2007 10:10:44, Tamir Weiss
<tamir.we...@gmail.composted:
I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.
The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.

It is clear what your problem is; it is that you have done something
wrong.

A better description of what code you use might render possible a more
specific response. However, as you asked no question, you may not be
expecting any answer.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?...@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
The encoding in JavaScript is done using the webtoolkit.base64 encoder
(on FireFox, but I'd imagine it would work on both).
The decoding is done using the org.apache.commons.codec library.

I'm not using any special parameters on neither sides, so I didn't
want to give any meaningless details.
I'm pretty new to all the javascript and base64 thing, so I'm
suspecting something in my HTML\Servlet is misconfigured.

If you've seen something like that, please tell me what helped you.

May 15 '07 #4
On 14 May, 18:10, Tamir Weiss <tamir.we...@gmail.comwrote:
I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.

The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.
Hi

I don't think you have provided enough information for the question to
be answered.

1. JavaScript does not have a "byte" value, so what do you mean by
"byte array"? Do you mean a JavaScript "Array" of JavaScript
"Number"?

2. How did you manage to load a JPG image into a JavaScript Array in
the first place?

What method did you use? I.e. are you sure that you really did manage
to get a JPG into a JavaScript Array of Numbers without any error?

It is possible to load binary in JavaScript, provided the client
browser has the necessary security permissions. Microsoft have a
number of Active X objects, such as ADODB.Stream and
Scripting.FileSystemObject . It is possible to use
Scripting.FileSystemObject to read binary files, contrary to popular
opinion, but it is a little tricky, and it requires a knowledge of
Windows code pages and the difference between the TextStream.Read and
ReadAll methods.

3. How are you sending the encoded Base64 to the servlet?

4. You may wish to test whether webtoolkit's base64 encoder is
actually working properly.

Julian


May 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Karl Pech | last post by:
Hi all, I'm trying to write a program which can read in files in the following format: sos_encoded.txt: --- begin-base64 644 sos.txt UGxlYXNlLCBoZWxwIG1lIQ== ---
3
by: Patrick | last post by:
Hi... I have a problem with Mime/base64 decoding. Maybe someone can help. I have an original Text, that I send using outlook. The text is: "This is a testmail ä ü ö é à è" (without the ") So...
1
by: Damir Hakimov | last post by:
Hi *! I found a strange bug in base64.encode and decode, when I try to encode - decode a file 1728512 bytes lenth. Is somebody meet with this? I don't attach the file because it big, but can...
27
by: gRizwan | last post by:
Hello all, We have a problem on a webpage. That page is sent some email data in base64 format. what we need to do is, decode the base64 data back to original shape and extract attached image...
1
by: scott | last post by:
Hi all, trying to use base64. Ill get right to the problem. I am converting a string into base 64. No problem there. That base64 string can then be converted back to the orignal string. No...
0
by: Phil C. | last post by:
(Cross post from framework.aspnet.security) Hi. I testing some asp.net code that generates a 256 bit Aes Symmetric Key and a 256 bit entropy value. I encrypt the Aes key(without storing it as...
7
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...
5
by: Jay | last post by:
I have bean trying to get my head around reading .GIF files from base64 strings, Basically I need to specify a filename and convert it to base64 then I can copy/past the string to wear I want it....
14
by: BB | last post by:
Hello. i am trying to decode a block of (what i think is) base64 into text, and i have NO idea how to begin. I'm going to paste the whole string here, but i want to know the steps necessary to...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.