Skip to content

How to handle binary download from an http get #398

Open
@joekane101

Description

@joekane101

Short of the ongoing topic of binary upload and download, I am trying to download some files (and save as binary files) from an http get. By setting the webformat to PlainText, and then saving the response.body to a file via adodb.stream, this works most of the time. JPEG files have been mostly working well, but for some other types I am seeing the error from Webresponse.CreateFromHTTP:

ERROR - WebResponse.CreateFromHttp: -2147210474 (11030 / 80042b16), An error occurred while creating response from http
-2147023783 (80070459): No mapping for the Unicode character exists in the target multi-byte code page.

This is from the same comment that Tim mentioned here on 110.
https://github.com/VBA-tools/VBA-Web/issues/110#issuecomment-102888615

The raw binary from some files chokes the line:
Me.Content = Http.ResponseText

but CreateFromHTTP doesn't have context to know to skip the content assignment line.

I was trying to think of the easiest way to handle this. Looking at code, I suppose the recommendation might be to register custom converters, but I dont necessarily know the MIME types (all of them, anyway) in advance, and some get complicated (office files, for example).

I know that I'm asking for a binary payload; I was initially thinking I could specify a WebFormat of RAW or Binary, which would provide some context to not parse the content, but not one of the options today.

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions