uzluisf
uzluisf

Reputation: 3096

What's the difference between a byte stream and a byte string?

From the DocuSign documentation on documents, "when you add a document file to an envelope, the DocuSign platform converts it to PDF and stores it as base64-encoded ASCII" and then in REST API doc for getDocument, "by default, the response is the PDF file as a byte stream... By using the Content-Transfer-Encoding header in the request, you can obtain the PDF file encoded in base64." (emphasis mine)

This is what I understand thus far:

The use of the term "byte stream" is what confuses me here because DocuSign isn't streaming the file (e.g., as I understand it streaming implies consuming from/writing to a resource chunk by chunk instead of as a whole). Assuming I'm correct, then a better term is byte string. Hence my questions:


  1. From NodeJS Buffer docs: "'binary': Alias for 'latin1'. The name of this encoding can be very misleading, as all of the encodings listed here convert between strings and binary data. For converting between strings and Buffers, typically 'utf8' is the right choice."

Upvotes: 0

Views: 214

Answers (1)

Larry K
Larry K

Reputation: 49114

The response is the file as a byte string, it is not a JSON response.

You are correct, the right terminology is byte string, not byte stream. We'll get the docs updated.

If you download as a byte string, it won't be encoded. It will be in binary. If your client can't handle that, then download with base64 encoding and then decode to binary.

Upvotes: 1

Related Questions