Skip to content

Storage: image upload problem #8046

@melih9779

Description

@melih9779

When upload file, I get sometimes error

upload:

def upload_to_bucket(blob_name, path_to_file, bucket_name='testBucket'):
    storage_client = storage.Client.from_service_account_json('/home/pi/Desktop/keyfile.json')
    time.sleep(2)
    #print(buckets = list(storage_client.list_buckets())

    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(blob_name)
    try:
        blob.upload_from_filename(path_to_file)
        blob.make_public()
    except Exception as e:
        return False
    else:
        return True

Error:

Traceback (most recent call last):
  File "/home/pi/Desktop/boot.py", line 130, in <module>
    if(upload_to_bucket(gcloud_save_path,image_name)):
  File "/home/pi/Desktop/boot.py", line 21, in upload_to_bucket
    bucket = storage_client.get_bucket(bucket_name)
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/storage/client.py", line 227, in get_bucket
    bucket.reload(client=self)
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/storage/_helpers.py", line 130, in reload
    _target_object=self,
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/_http.py", line 392, in api_request
    target_object=_target_object,
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/_http.py", line 269, in _make_request
    return self._do_request(method, url, headers, data, target_object)
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/_http.py", line 298, in _do_request
    return self.http.request(url=url, method=method, headers=headers, data=data)
  File "/usr/local/lib/python3.5/dist-packages/google/auth/transport/requests.py", line 205, in request
    self._auth_request, method, url, request_headers)
  File "/usr/local/lib/python3.5/dist-packages/google/auth/credentials.py", line 122, in before_request
    self.refresh(request)
  File "/usr/local/lib/python3.5/dist-packages/google/oauth2/service_account.py", line 320, in refresh
    assertion = self._make_authorization_grant_assertion()
  File "/usr/local/lib/python3.5/dist-packages/google/oauth2/service_account.py", line 314, in _make_authorization_grant_assertion
    token = jwt.encode(self._signer, payload)
  File "/usr/local/lib/python3.5/dist-packages/google/auth/jwt.py", line 97, in encode
    signature = signer.sign(signing_input)
  File "/usr/local/lib/python3.5/dist-packages/google/auth/crypt/_cryptography_rsa.py", line 126, in sign
    message, _PADDING, _SHA256)
  File "/usr/lib/python3/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 463, in sign
    algorithm, self, data
  File "/usr/lib/python3/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 241, in _rsa_sig_sign
    assert errors[0].lib == backend._lib.ERR_LIB_RSA
AssertionError

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.authtype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions