title: Getting gzip.BadGzipFile: Not a gzipped file (b"b'") when decompressing a received message
body: <p>I have an html file named <code>75842.html</code> and I am compressing the file with gzip by doing the following:</p>
  <pre><code>with open('75842.html', 'rb') as f:
      body_compressed=gzip.compress(f.read())
  </code></pre>
  <p><code>body_compressed</code> is a <code>&lt;class 'bytes'&gt;</code> object.</p>
  <p>I cannot send bytes through SQS, the message body needs to be a string. So I'm defining <code>MessageBody=str(body_compressed)</code> when sending the file.</p>
  <p>When reading the message on another server, I would like to decompress and save it using:</p>
  <pre><code>with open('75842_decompressed.html', 'w') as f:
      f.write(gzip.decompress(str.encode(body)))
  </code></pre>
  <p>I get then the error message <code>gzip.BadGzipFile: Not a gzipped file (b&quot;b'&quot;)</code>. Probably because the file starts with a b'. However, I'm unsure how to solve it. Any help is much appreciated.</p>