title: How to write raw bytes to Google cloud storage with GAE's Python API
body: <p>I am trying to modify some binary data submitted by user form, and write it to Google Cloud Storage. I tried to follow <a href="https://developers.google.com/appengine/docs/python/googlecloudstorageclient/getstarted" rel="noreferrer">Google document's  example</a>, but upon writing I got errors such as:</p>
  
  <blockquote>
    <p>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 34: ordinal not in range.</p>
  </blockquote>
  
  <p>My code is simply as below</p>
  
  <pre><code>gcs_file = gcs.open(filename,'w',content_type='audio/mp3')
  gcs_file.write(buf)
  gcs_file.close()
  </code></pre>
  
  <p>I tried to open file with 'wb' mode but got a "Invalid mode wb." error.</p>
  
  <p>I found a similar question at <a href="https://groups.google.com/forum/#!topic/gs-discussion/rxOdBEVFAjI" rel="noreferrer">GCS's maillist</a> which was on Java. There the GCS develop team's suggest was to use writeChannel.write() instead of PrintWriter. Could anybody suggest how to make it work in Python?</p>