title: How to start google cloud storage resumable upload?
body: <p>I'm trying to create a GCS resumable upload url on the backend, send it to the frontend to get javascript to start a big file upload directly to the bucket.</p>
  <p>My problem, currently, is that I can't figure out how to start the upload.</p>
  <p>All the <a href="https://developers.google.com/storage/docs/json_api/v1/how-tos/upload#start-resumable" rel="nofollow noreferrer">documentation</a> doesn't have any code, so there is nothing for me to be based on.</p>
  <p>My code, currently, is this:</p>
  <pre><code>def start_resumable_upload(self):
      API_ENDPOINT = (
          'https://www.googleapis.com/upload/storage/v1beta2/'
          'b%(bucket)s/o?uploadType=resumable&amp;name=%(object_name)s'
      )
      url_params = {
          'bucket': BUCKET,
          'object_name': self.filename
      }
      headers = {
          'X-Upload-Content-Type': self.content_type,
          'X-Upload-Content-Length': 0,
          'Content-Type': 'application/json'
      }
      r = urlfetch.fetch(
          url=API_ENDPOINT % url_params,
          method=urlfetch.POST,
          headers=headers
      )
      return r.content
  </code></pre>
  <p>start_resumable_upload is a method within the file Model I created to keep track of metadata on the database, thus, self.filename will have the filename, content_type will be the mime type and so on.</p>
  <p>The response of that request is:
  <p><b>400.</b> That’s an error.
  <p>Your client has issued a malformed or illegal request.  That’s all we know.        </p>
  <p>which is somewhat unacceptable.</p>
  <p>Any help is appreciated.</p>