How to upload files to Cloud Storage with Firebase's python SDK

Note

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore, storage

cred = credentials.Certificate('your-cred.json')
firebase_admin.initialize_app(cred, {'storageBucket': '<bucket-name>'})

bucket = storage.bucket()

filename = 'image.png'
content_type = 'image/png'
blob = bucket.blob(filename)
with open(filename, 'rb') as f:
    blob.upload_from_file(f, content_type=content_type)

Ref

Recommended Posts

How to upload files to Cloud Storage with Firebase's python SDK
Upload files to Aspera that comes with IBM Cloud Object Storage (ICOS) using SDK (Python version)
Upload file to GCP's Cloud Storage (GCS) ~ Load with local Python
How to upload with Heroku, Flask, Python, Git (4)
Upload files to Google Drive with Lambda (Python)
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]
How to upload with Heroku, Flask, Python, Git (Part 3)
How to upload with Heroku, Flask, Python, Git (Part 1)
How to upload with Heroku, Flask, Python, Git (Part 2)
How to get started with Python
How to use FTP with Python
How to calculate date with python
Let's use Watson from Python! --How to use Developer Cloud Python SDK
Upload and delete files to Google Cloud Storages with django-storage
File upload to Azure Storage (Python)
[GCP] How to publish Cloud Storage signed URLs (temporary URLs) in Python
How to import CSV and TSV files into SQLite with Python
How to connect to Cloud Firestore from Google Cloud Functions with python code
Image upload & download to Azure Storage. With Python + requests + REST API
How to work with BigQuery in Python
How to do portmanteau test with python
How to display python Japanese with lolipop
[GCP] Operate Google Cloud Storage with Python
How to switch python versions in cloud9
How to enter Japanese with Python curses
Convert HEIC files to PNG files with Python
[Python] How to deal with module errors
Upload images to Google Drive with Python
How to install python3 with docker centos
How to automatically upload .gpx files to Strava
[Cloudian # 1] Try to access object storage with AWS SDK for Python (boto3)
Convert the spreadsheet to CSV and upload it to Cloud Storage with Cloud Functions
Copy data from Amazon S3 to Google Cloud Storage with Python (boto)
How to deal with old Python versions in Cloud9 made by others
How to enjoy programming with Minecraft (Ruby, Python)
[REAPER] How to play with Reascript in Python
How to do multi-core parallel processing with python
Summary of how to import files in Python 3
How to crop an image with Python + OpenCV
How to specify attributes with Mock of python
How to measure execution time with Python Part 1
How to get the files in the [Python] folder
How to use tkinter with python in pyenv
Convert files uploaded to Cloud Storage with Cloud Functions (Python) so that they are not garbled in Excel
[Python] How to handle Japanese characters with openCV
[Python] How to compare datetime with timezone added
How to measure execution time with Python Part 2
How to get a list of files in the same directory with python
Upload files with Django
How to install Python
GAE --With Python, rotate the image based on the rotation information of EXIF and upload it to Cloud Storage.
How to convert / restore a string with [] in python
How to scrape image data from flickr with python
How to do hash calculation with salt in Python
[Introduction to Python] How to iterate with the range function?
How to run tests in bulk with Python unittest
[Python] How to specify the download location with youtube-dl
How to load files in Google Drive with Google Colaboratory
How to measure mp3 file playback time with python
How to use python interactive mode with git bash
How to convert JSON file to CSV file with Python Pandas