HTTPSocket DownloadComplete FolderItem Encoding

How do you set the encoding on the FolderItem that the response is directly downloaded to in the HTTPSocket DownloadComplete event?

Similarly, when sending a picture as a binary data attachment using HTTP POST, do you need to use DefineEncoding? The picture data is stored in the database as string and is retrieved using StringValue.

Thank you

If the file is being download directly into a FolderItem then the text encoding is not important until you open the file for reading. The Read method of classes like BinaryStream and TextInputStream accepts an optional second parameter for defining the text encoding.

When sending binary data like a Picture, then no text encoding should be used at all (since it’s not text.)

I use LoadXML on the file, but I noticed there’s no parameter for encoding. I guess that’s because it takes it automatically from the xml prolog line?

[quote=207882:@Andrew Lambert]
When sending binary data like a Picture, then no text encoding should be used at all (since it’s not text.)[/quote]

Ok, the attachment is, but when doing a multi part POST, do you have to set the encoding on the different parts of the POST that are not the attachment itself?

Thanks

I’m not sure how Xojo handles XML encoding.

The encoding of individual parts of a multipart/form-data message can be set in the part’s Content-Type header, as the CharSet parameter. For example, setting the encoding of a multipart form’s file part to UTF-8:

Content-Disposition: form-data; name="File"; filename="MyFile.html"
Content-Type: text/html; CharSet=UTF-8

File parts containing binary data should not specify a CharSet in the Content-Type header.

See here if you need code to generate a multipart form in Xojo; the Content-Type for file parts is set on line 18.