3

We have a media file repository, with which other services communicate over a REST API. For various reasons we want the users of the repository to be able to upload and download files over HTTP both directly (plaintext for text files and byte array for binary files) and using Base64 encoding. We want the fact that the file is uploaded (PUT, POST) and requested for download (GET) in the Base64 encoding be reflected in the header of the HTTP request.

How do we reflect the fact that the content of the request or requested response is Base64 encoded in the HTTP header?

So far I'm tending towards appending ;base64 after the mime type in the Content-Type header, for example Content-Type: image/png;base64. Other options (X- header, Content-Encoding) are discussed in this related question but do not offer satisfactory resolution to our question.

Pavel
  • 698
  • 1
  • 11
  • 20

1 Answers1

2

You have to use Content-Transfer-Encoding header.

It is in RFC https://www.rfc-editor.org/rfc/rfc2045#page-14.

It supports base64 value among others, like "7bit" / "8bit" / "binary" / "quoted-printable" / "base64" / ietf-token / x-token

This header is specially designed for your case, to use as a complement for MIME type.

Community
  • 1
  • 1
grapes
  • 8,185
  • 1
  • 19
  • 31