[Django]-Upload image to Firebase Storage from django models in FileField

3👍

You’re going to want to use google-cloud-storage for this:

# Import
from google.cloud import storage

# Initialize
client = storage.Client()
bucket = client.get_bucket('bucket-id-here')

# Download
blob = bucket.get_blob('remote/path/to/file.txt')
print(blob.download_as_string())

# Upload
blob2 = bucket.blob('remote/path/storage.txt')
blob2.upload_from_filename(filename='/local/path.txt')

Leave a comment