Page 1 of 1

HttpRequest:Content and binary data

Posted: Tue Nov 23, 2021 1:10 pm
by Sbryan
Part of my application allows the upload of images to the server using a multi-part form and I'm using Chilkat's Mime functions to save the images but I've run into a problem. I've been working with Matt Fausey of Chilkat trying to figure it out and he said it looks like HttpRequest:Content is converting the binary data of the mime message to utf-16 which is causing the issue.

Since the documentation is still pretty sparse even after all these years, I've been unable to find out much about it and was wondering if there is a way to prevent it from converting the image data. Or, is there a way with the Foundation version of CXP to save the files directly?

Re: HttpRequest:Content and binary data

Posted: Tue Nov 23, 2021 6:47 pm
by Sbryan
After some searching I realized there is a sample for saving files in the cxp web samples which I was able to use and can get it save files based on the settings in global.config.
My question now is, How do I properly save the file from the oHttpUploadedFile:Data if I want to?

Re: HttpRequest:Content and binary data

Posted: Wed Nov 24, 2021 2:32 am
by Tom
We use Base64-encoding for any kind of binary data transported from or to our servers.

Re: HttpRequest:Content and binary data

Posted: Wed Nov 24, 2021 5:53 am
by Sbryan
Thanks Tom,

I understand the need for converting binary data to base64 for transporting but I'm a little confused how to convert it in the client browser before sending to the server. I was under the impression (obviously wrong) that modern browsers automatically encoded data during a POST.