首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >google.auth.exceptions.RefreshError

google.auth.exceptions.RefreshError
EN

Stack Overflow用户
提问于 2019-04-10 22:33:06
回答 1查看 2.2K关注 0票数 1

我的问题是,我无法将文件添加到我的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'

servname : HTTPConnectionPool(host='metadata.google.internal',port=80):超过了url: /computeMetadata/v1/instance/service-accounts/default/?recursive=true的最大重试次数(由google.auth.exceptions.RefreshError(‘:无法建立新连接: Errno 8 port=80未提供,或未知’)引起)

EN

回答 1

Stack Overflow用户

发布于 2019-04-11 01:36:18

该错误表明您的进程无法找到metadata.google.internal。这可能是以下两种情况之一:

  1. 你没有在谷歌计算引擎上运行。只有在GCE上运行时,才会使用compute_engine.Credentials()。在其他系统上使用不同的凭据。(实际上,在GCE和GAE上,您根本不需要指定凭据-默认凭据是自动使用的)
  2. 在解析metadata.google.internal时遇到了DNS问题。确保metadata.google.internal解析为169.254.169.254.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55615171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档