我试图上传一个很长的文件列表到我的firebase桶,我使用python和firebase管理Sdk。我得到这个错误:
我得到的错误是:google.api_核心.异常。未找到:404后https://www.googleapis.com/upload/ 存储/v1/b/gs://bismart-def3c。appspot.com/o?uploadType=可恢复:('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)
我目前无法成功上传
我转而使用google云/存储api。我的文件很容易上传:
根据Docs。希望它能帮助任何人
相关问题 更多 >
编程相关推荐