我的问题是,我无法将文件添加到我的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未提供,或未知’)引起)
发布于 2019-04-11 01:36:18
该错误表明您的进程无法找到metadata.google.internal
。这可能是以下两种情况之一:
compute_engine.Credentials()
。在其他系统上使用不同的凭据。(实际上,在GCE和GAE上,您根本不需要指定凭据-默认凭据是自动使用的)metadata.google.internal
时遇到了DNS问题。确保metadata.google.internal
解析为169.254.169.254.https://stackoverflow.com/questions/55615171
复制相似问题