title: Binary data over AWS Lambda triggered by API Gateway
body: <p>I know there are several similar questions regarding this topic, but I haven't found my exact problem yet. If there is one, forgive me and please send me the link :-)</p>
  
  <p>I have a lambda function that is triggered by API Gateway and returns a base64 encoded string of a image/tiff file.</p>
  
  <p>I edited the API Gateway configurations so that it converts the string back to binary data.</p>
  
  <p>If I test all this with the AWS functionality directly on, the binary image code (.tiff file) is correctly displayed. </p>
  
  <p><a href="https://i.stack.imgur.com/O0pSb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O0pSb.png" alt="It works!"></a></p>
  
  <p>However, if I test it via Postman, the downloaded file still contains the base64 encoded string and would need to be decoded. Thus, I cannot directly download the file from the API, but would have to do some conversion on the client side, right?</p>
  
  <p><a href="https://i.stack.imgur.com/ZGBW7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZGBW7.png" alt="enter image description here"></a></p>
  
  <p>This is the header I receive from my API via Postman:
  <a href="https://i.stack.imgur.com/WBTw1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WBTw1.png" alt="enter image description here"></a></p>
  
  <p>I included my <code>Accept</code> header as well: <code>image/tiff</code></p>
  
  <p>My python lambda backend return looks like this:
  <code>return base64.b64encode(binary_data).decode('ascii')</code></p>
  
  <p>Why does it convert to binary data on the AWS console, but not via Postman (or curl)? I am a bit lost. Here my settings for the integration response:
  <a href="https://i.stack.imgur.com/NsKb5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NsKb5.png" alt="enter image description here"></a></p>
  
  <p>In the end, I'd like to set all this via serverless, but I am already happy to get it to work via the web frontend and migrate to serverless later on.</p>
  
  <p>Thanks in advance for your help.</p>