google.auth.exceptions.RefreshError - PullRequest
0 голосов
/ 10 апреля 2019

Моя проблема в том, что я не могу добавить файл в свое хранилище облачного хранилища Google

def upload():
    from flask import request
    """Process the uploaded file and upload it to Google Cloud Storage."""
    uploaded_file = request.files.get('file')

    if not uploaded_file:
        return 'No file uploaded.', 400

    # Create a Cloud Storage client.
    credentials = compute_engine.Credentials()
    gcs = storage.Client(credentials=credentials, project="ISL-Creative")
    # gcs = storage.Client()
    # Get the bucket that the file will be uploaded to.
    bucket = gcs.get_bucket('label_creative')
    # Create a new blob and upload the file's content.
    blob = bucket.blob(uploaded_file.filename)
    blob.upload_from_string(
        uploaded_file.read(),
        content_type=uploaded_file.content_type
    )

    # The public URL can be used to directly access the uploaded file via HTTP.
    return 'ok'

google.auth.exceptions.RefreshError: HTTPConnectionPool (host = 'metadata.google.internal', port = 80): превышено максимальное количество повторов с URL: / computeMetadata / v1 / instance / service-account / default /? Recursive = true (вызвано NewConnectionError (': не удалось установить новое соединение: [Errno 8] указано ни имя, ни имя сервера, либо неизвестно "))

1 Ответ

0 голосов
/ 10 апреля 2019

Ошибка показывает, что ваш процесс не может найти metadata.google.internal. Это, вероятно, либо:

  1. Вы не используете Google Compute Engine. compute_engine.Credentials() предназначен только для работы на GCE. Используйте другие учетные данные в других системах. (на самом деле в GCE и GAE вам вообще не нужно указывать учетные данные - учетные данные по умолчанию используются автоматически)

  2. У вас есть проблема с разрешением DNS metadata.google.internal. Убедитесь, что metadata.google.internal разрешено в 169.254.169.254.

...