<p>We get this error when uploading a large file (more than 10Mb but less than 100Mb):</p>

<pre><code>403 POST https://www.googleapis.com/upload/storage/v1/b/dm-scrapes/o?uploadType=resumable: ('Response headers must contain header', 'location')
</code></pre>

<p>Or this error when the file is more than 5Mb</p>

<pre><code>403 POST https://www.googleapis.com/upload/storage/v1/b/dm-scrapes/o?uploadType=multipart: ('Request failed with status code', 403, 'Expected one of', &lt;HTTPStatus.OK: 200&gt;)
</code></pre>

<p>It seems that this API is looking at the file size and trying to upload it via multi part or resumable method. I can't imagine that is something that as a caller of this API I should be concerned with. Is the problem somehow related to permissions? Does the bucket need special permission do it can accept multipart or resumable upload. </p>

<pre><code>from google.cloud import storage

try:
    client = storage.Client()
    bucket = client.get_bucket('my-bucket')
    blob = bucket.blob('blob-name')
    blob.upload_from_filename(zip_path, content_type='application/gzip')

except Exception as e:
    print(f'Error in uploading {zip_path}')
    print(e)
</code></pre>

<p>We run this inside a Kubernetes pod so the permissions get picked up by storage.Client() call automatically. </p>

<p>We already tried these:</p>

<ul>
<li><p>Can't upload with gsutil because the container is Python 3 and <a href="https://github.com/GoogleCloudPlatform/gsutil/issues/29" rel="noreferrer">gsutil does not run in python 3</a>.</p></li>
<li><p><a href="https://dev.to/sethmichaellarson/python-data-streaming-to-google-cloud-storage-with-resumable-uploads-458h" rel="noreferrer">Tried this example</a>:  but runs into the same error:  <code>('Response headers must contain header', 'location')</code></p></li>
<li><p><a href="https://googlecloudplatform.github.io/google-resumable-media-python/latest/google.resumable_media.requests.html#resumable-uploads" rel="noreferrer">There is also this library.</a> But it is basically alpha quality with little activity and no commits for a year. </p></li>
<li>Upgraded to google-cloud-storage==1.13.0</li>
</ul>

<p>Thanks in advance</p>

David Dehghan
<p>The problem was indeed the credentials. Somehow the error message was very miss-leading. When we loaded the credentials explicitly the problem went away. </p>

<pre><code> # Explicitly use service account credentials by specifying the private key file.
 storage_client = storage.Client.from_service_account_json(
        'service_account.json')
</code></pre>
