I am trying to upload a very long list of files to my fire-base bucket.I am using python and firebase admin Sdk. I get this error:
So here is the error that i get: google.api_core.exceptions.NotFound: 404 POST https://www.googleapis.com/upload/ storage/v1/b/gs://bismart-def3c.appspot.com/o?uploadType=resumable: ('Response headers must contain header', 'location')
import os
import firebase_admin
from firebase_admin import credentials, firestore, storage
path = 'G:\\JURISPRUDENCE'
files = []
fileN = []
cred = credentials.Certificate("C:\Users\George\bismart-def3c-firebase-adminsdk-ib3f9-6a1f172321.json")
firebase_admin.initialize_app(cred, {
'storageBucket': 'gs://bismart-def3c.appspot.com'
})
def upload(file,name):
db = firestore.client()
bucket = storage.bucket()
blob = bucket.blob(name)
outfile=file
with open(outfile, 'rb') as my_file:
blob.upload_from_file(my_file)
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
for file in f:
if '.docx' in file:
files.append(os.path.join(r, file))
upload(os.path.join(r, file),file)
fileN.append(file)
for f in files:
for k in fileN:
print("uploaded" + k)
I currently dont succeed in making the upload
storageBucket
should just be the name of the bucket with any prefixes likegs://
– Hiranya Jayathilaka