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'
< /code>
Dies ist der Fehler: < /p>
google.auth.exceptions.RefreshError: HTTPConnectionPool(host='metadata.google.internal', port=80): Max retries exceeded with url: /computeMetadata/v1/instance/service-accounts/default/?recursive=true (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
Mein [url=viewtopic.php?t=11587]Problem[/url] ist, dass ich meinem Google Cloud -Speicherbucket keine Datei hinzufügen kann. < /p> [code]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' < /code> Dies ist der Fehler: < /p> google.auth.exceptions.RefreshError: HTTPConnectionPool(host='metadata.google.internal', port=80): Max retries exceeded with url: /computeMetadata/v1/instance/service-accounts/default/?recursive=true (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')) [/code]
Ich versuche eine Verbindung zum Google Drive herzustellen, um einige Vorgänge im Laufwerksordner auszuführen. Ich habe eine Funktion gebaut und es hat funktioniert. Aber als ich versuchte, OOP und...
Ich bin ein Neuling auf diesem Gebiet.
Ich bin auf diesen Fehler gestoßen und habe keine Ahnung, was ich falsch gemacht habe. Ich habe im Internet nachgeschlagen und es scheint, als wäre ich der Nur...
Ich versuche, mithilfe von Flask einige Daten aus einem Formular auf meiner Website abzurufen, und es wird „requests.Exceptions.HTTPError: 400 Client Error: Bad Request for url:“ ausgegeben, und ich...
Ich versuche Scrapy in Django implementieren. Dafür hat mir dieses Thema geholfen. Ich schrotte keine Website. myspider.py :
from scrapers.items import ScrapersItem
Ich schreibe einen Code mit Selen und stelle an einem Punkt 7 Anfragen auf verschiedene Websites. Für den ersten funktioniert dies einwandfrei. Für andere erhalte ich jedoch einen Sitzungs -ID...