Created
April 22, 2019 18:24
-
-
Save Gabri3l/92a5e2a5da79e49c4a54e968249325b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
import json | |
from google.cloud import storage | |
def upload_from_temp_file(some_data): | |
with tempfile.NamedTemporaryFile() as fp: | |
json_data = json.dumps(some_data) | |
fp.write(json_data.encode()) | |
fp.flush() | |
with open(fp.name, "rb") as f: | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket('my_bucket') | |
blob = bucket.blob("some_cool_name.json") | |
blob.upload_from_file(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment