getting base64 encoded string using IdHttp

yes hello good to be back...

so i have written a REST server in PHP to talk to my IdHttp client that 
base64 encodes a jpeg in order to send the data in a record "packet" of my 
own design.  I then use a TStringList.delimitedText to read the received 
packet and parse the results into key/value pairs (kind of a homestyle JSON 
format).

this is working well for all the other data, but it seems that the base64 
field is being limited to 4096 bytes when i call the 

RawByteString thumb64 := tsServerReply.Values['base64field'];

the original 'base64field' is a bit over 18k, but in the debugger the 
thumb64 string is exactly 4096 bytes long, and obviously i am unable to 
recreate the jpeg for display.

does anyone have any insights into this issue?

advTHANKSance,
-mark
0
mark
3/3/2009 3:23:35 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

6 Replies
2126 Views

Similar Articles

[PageSpeed] 5

mark enriqeuz wrote:

> does anyone have any insights into this issue?

You should decode the stream first.

Check the unit EncdDecd.pas, all methods is base 64.

procedure EncodeStream(Input, Output: TStream);
procedure DecodeStream(Input, Output: TStream);
function  EncodeString(const Input: string): string;
function  DecodeString(const Input: string): string;

function  DecodeBase64(const Input: AnsiString): TBytes;
function  EncodeBase64(const Input: Pointer; Size: Integer): AnsiString;

I use that to upload files to WordPress with XML-RPC
http://www.cesarromero.com.br/wordpress-xml-rpc-com-delphi-e-indy-10/
Article in Brazilian Portuguese, but the code sample can give you some
hints.



-- 
Cesar Romero
http://www.cesarromero.com.br
http://www.liws.com.br
0
Cesar
3/3/2009 3:36:45 PM
Cesar Romero <cesar@liws.com.br> wrote in news:87842@forums.codegear.com:

> unit EncdDecd.

very nice place to start...thxs for the quick reply.  i may hit you up for 
that code but for now i will try to get it working on my own.

best regards,
- mark
0
mark
3/3/2009 3:50:28 PM
"mark enriqeuz" <mark@usflowerhaus.com> wrote in message 
news:87830@forums.codegear.com...

> this is working well for all the other data, but it seems that
> the base64 field is being limited to 4096 bytes when i call the
>
> RawByteString thumb64 := tsServerReply.Values['base64field'];

TIdHTTP does not truncate data.  Either your server is truncating it, or 
your parsing of the data is.

> the original 'base64field' is a bit over 18k, but in the debugger the
> thumb64 string is exactly 4096 bytes long, and obviously i am unable to
> recreate the jpeg for display.

Please show your actual code.

-- 
Remy Lebeau (TeamB)
0
Remy
3/3/2009 8:31:07 PM
"Cesar Romero" <cesar@liws.com.br> wrote in message 
news:87842@forums.codegear.com...

> You should decode the stream first.
>
> Check the unit EncdDecd.pas, all methods is base 64.

Since he's already using Indy anyway, he can use Indy's own base64 decoder 
class (TIdDecoderMIME).

-- 
Remy Lebeau (TeamB)
0
Remy
3/3/2009 8:32:03 PM
Remy Lebeau (TeamB) wrote:

> > Check the unit EncdDecd.pas, all methods is base 64.
> 
> Since he's already using Indy anyway, he can use Indy's own base64
> decoder class (TIdDecoderMIME).

EncdDecd is from VCL, no need to get anyother.
And Im pretty sure it will give the same result tha TIdDecoderMime

-- 
Cesar Romero
http://www.cesarromero.com.br
http://www.liws.com.br
0
Cesar
3/3/2009 8:36:46 PM
"Cesar Romero" <cesar@liws.com.br> wrote in message 
news:88041@forums.codegear.com...

> EncdDecd is from VCL, no need to get anyother.

EncdDecd() is not part of the native VCL, it is part of Borland's SOAP 
framework.

-- 
Remy Lebeau (TeamB)
0
Remy
3/3/2009 8:50:43 PM
Reply:

Similar Artilces:

Encoding image to base64 string using javascript?
I need to encode an image to a base64 string on client side, does anyone has a script to do it? ThanksIf this post has been useful to you please mark it as answer. Take a look at this url, I think it contains the info you are looking for:  http://www.codeproject.com/useritems/Exsead1.asp  I tried that but couldn't manage to get it to work.If this post has been useful to you please mark it as answer....

Using Delphi XE/RTTI to get the Enum value based on an string
Hello, I was wondering, how I could get the EnumValue of an enumerated type based on a string using the new Rtti. I'm using the new Rtti to cponvert the EnumValue to string: TValue.From<TMyEnum>(EnumValue).ToString; But I would like to convert is back again: TValue.From<string>('EnumName').AsType<TMyEnum>; But this doesn't work (EConvertError in AsType...) Whe inspecting the internal code of the Rtti unit, I foudn there is an (private) object regarding Enum-types called TRttiEnumerationType which containts a function GetValue...

Dynamic Image(s) in page using Base64 encoded string as image source
First of all, I'm not sure where to put this in the forum.  Second, Here's my problem. I have access to a webservice that, based upon search params, will return a string array of base64 encoded images.  Now, the client application has to display those images.  Since the images come from a protected image server, I cannot use static paths or anything.  All I have to work with are the base64 encoded image strings that are returned from the service.  That's it! I am having trouble figuring out how to display these in the page once when I get them.&nbs...

Encoding into ASCII text using base64 encoding
how can i use asp.net to encoding a fle into ASCII text using base64 encoding. byte[] buffer = System.Text.ASCIIEncoding.ASCII.GetBytes( "Your string here" );string stuff = System.Convert.ToBase64String( buffer ); Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!...

To Encode String or to Not Encode String... Answer?
I am importing a CSV file from a Unix server as a string, and then saving the string into a new file for later processing.  However, this process does not always work.  As this CSV file is VERY, VERY large, I am unable to immediately tell if the fault lies with my code, or the CSV file provider (very possible).  The only time I can tell that this happened is when the data is not populated the next morning.  The fault appears to lie in there being extra or missing commas, as when I try to run the data import manually, STRINGs are attempted to be inserted into INT...

How to get encoding of string
I need to get encoding of some string. how can I do it? ThanksIreland's classifieds | UK classifieds...

Best Place to get help on converting Delphi 2007 string to Delphi 2009
Where is the best place to get help on converting Delphi 2007 strings to Delphi 2009? The most common problem getting Delphi 7-Delphi 2007 components to compile seems to be caused by the new Unicode strings in Delphi 2009. It would be great if there was some place to go to get help with this. Maybe there should be a new group for String conversion where developers could ask short questions about conversion. For example: Delphi 7 - Delphi 2007 CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; Compiles Delphi 2009 CharArrayPtr = ^CharArray; CharArray ...

Encoding a string to base64
Hi, I recently downloaded a source code (n_cryptoapi) which i have tried using to encode a string to base64 but i'm getting incorrect results. string = 0116112006003 actual result = MAAxADEANgAxADEAMgAwADAANgAwADAAMwA= expected result = MDExNjExMjAwNjAwMw what am i doing wrong? I'm using the encode64 function = String ls_encoded ULong lul_len, lul_buflen Boolean lb_rtn lul_len = Len(ablob_data) lul_buflen = lul_len * 2 ls_encoded = Space(lul_buflen) lb_rtn = CryptBinaryToString(ablob_data, & lul_len, CRYPT_STRING_BASE64, & ls_encoded, lu...

Base64 encoding
Hi, I have to encode / decode binary data. With Delphi XE2 I found two functions: - TIdDecoderMIME class from Indy Library - EncodeBase64 / DecodeBase64 from unit Soap.EncdDecd As far as I understand, both do the same. So what is the prefered function to use? Or are there differences? cu Christian Christian, > As far as I understand, both do the same. So what is the prefered > function to use? Or are there differences? although Indy ships with Delphi it is a third party component. As long as possible it is the preferred way to use the Delphi functionality. -- ...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application
 Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application  please help me? Friend, Web.config has its own advantages. 1) Web.Config is used to store the important information like connections strings etc...so that it can be modified even after the code has been    deployed to the server without compiling the entire application again. 2) Since it is a XML file, there is no need of building the project of you are going to change the connection strings.   If you go for the class files,...

Getting a base64 string from a webactivity
I was wondering if i could get a base64 string from a webactivity after cal= ling the camera or=A0 the gallery and picking an image=0Ais this possible? = any sample?=0A ...

Base64 encode zipped string
Hello Group, I want to create a set of functions that allows me to do the following: function CompressAndEncodeString(InString: string): string; begin CompressInString using zip algo or whatever Base64 encode compressed Instring and assign to result end; and function RetrieveString(Instring: string): string begin Base64 decode Instring Uncompress decodestring and assign to result end; Googled for the different parts, but got lost in the complexity. Any help is very much appreciated! Willem -- Willem van Deursen, The Netherlands wvandeursen_nospam@...

check if string is base64 encoded
hey allcurrently i use the following piece of code to check if the string passed to me can be converted to base64, it is not very efficient and bad, can someone please suggest another of doing thisprivate string ConvertBase64ToString(string[] content){StringBuilder sb = new StringBuilder();int i = content.GetUpperBound(0);for (int j=0; j&lt;i; j++){try{// if successful in converting base64 append it.sb.Append(ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(content.GetValue(j).ToString())));}catch (Exception){// cannot be decoded so append the original stringsb.Append(content.GetVa...

Web resources about - getting base64 encoded string using IdHttp - embarcadero.delphi.winsock

Ted Cruz says Donald Trump becoming 'rattled' by his gains
WASHINGTON, New Hampshire (AP) — Ted Cruz accused his Republican rival Donald Trump Monday of exhibiting inconsistent conservativism and said ...

Exclusive: Hellenic Petroleum to meet Iran oil officials on Friday
Hellenic Petroleum, Greece's biggest oil refiner, will meet top Iranian oil officials on Friday to discuss crude oil imports from Iran, a company ...

Nina Simone Sings a Song for MLK in Trailer for Netflix Doc
Nina Simone sings a song mourning the death of Martin Luther King, Jr. in the first trailer for Netflix documentary “What Happened, Miss Simone?” ...

62 richest people have as much as wealth as half of world’s population, report finds
The 62 richest people on the planet have as much wealth as the poorest half of the world’s population, according to a new report from Oxfam. ...

Spike Lee to Boycott Oscars Because They’re Too White
Director Spike Lee announced Monday that he would be boycotting the 2016 Academy Awards, protesting the lack of minority nominees. “I would ...

WhatsApp drops subscription fee, goes completely free
Unlike most popular messaging apps, WhatsApp, the messaging service that Facebook bought in 2014 , charges a $1 annual subscription fee after ...

SpaceX Fails To Land Rocket On A Ship Yet Again
SpaceX has already tried to land its Falcon 9 reusable rocket on a floating ship in the ocean multiple times and, unfortunately, it has not been ...

David Bowie Gets His Own Constellation
What better way to honor David Bowie than by naming a constellation after the iconic artist. The world continues to mourn the passing of this ...

Utah Officer Was Paying off Cancer Bills When He Was Killed
Officials say the veteran Utah police officer who was working overtime to pay for his cancer treatments was shot to death by a fugitive who went ...

More National Guard Troops Move into Flint as Water Crisis Widens
NBCNews.com More National Guard Troops Move into Flint as Water Crisis Widens NBCNews.com The National Guard sent dozens of additional members ...

Resources last updated: 1/18/2016 8:22:09 PM