I’m trying to use TDownloadURL.DownloadRawBytes from the Rest.Client unit to download a PDF file from an Amazon S3 bucket.
My problem seems to be an empty ContentType returned with the file. I don’t control the server side and don’t have any way to get them to correctly set the ContentType.
TRESTRequest.Execute looks at the returned context type, if it is empty then it forces the MimeKind to TMimeTypes.TKind.Text. That in turn forces the returned Bytes to be converted to a string.
There is a way to pass in a different string encoding, but not a way to force a MimeType or to skip the string conversion.
Without that when I Execute the request I get the following error:
Project raised exception class EEncodingError with message ‘No mapping
for the Unicode character exists in the target multi-byte code page’.
- Is there a different method I should be using?
- Am I missing a way to force to binary or otherwise skip the string conversion?
- Is there a TEncoding option that will never fail? I was looking for some type of hex encoding that could encode everything, but didn’t see anything.