如何从firebase storage-Python获取PDF数据?

如何从firebase storage-Python获取PDF数据?,python,google-cloud-storage,firebase-storage,Python,Google Cloud Storage,Firebase Storage,我正在尝试从firebase/google存储将pdf文件数据输入到我的代码中 这是我到目前为止所做的 from google.cloud import storage from firebase import firebase firebase = firebase.FirebaseApplication('https://test.firebaseio.com/') client = storage.Client() bucket = client.get_bucket('test.app

我正在尝试从firebase/google存储将pdf文件数据输入到我的代码中

这是我到目前为止所做的

from google.cloud import storage
from firebase import firebase

firebase = firebase.FirebaseApplication('https://test.firebaseio.com/')
client = storage.Client()
bucket = client.get_bucket('test.appspot.com')
blob = bucket.blob('Motivation_Letter.pdf')

blob.download_as_string()
我得到这种输出。我怎样才能使它可读

b'%PDF-1.7\r\n%\xb5\xb5\xb5\xb5\r\n1 0 obj\r\n<</Type/Catalog/Pages 2 0 R/Lang(en-US) /StructTreeRoot 15 0 R/MarkInfo<</Marked true>>/Metadata 44 0 R/ViewerPreferences 45 0 R>>\r\nendobj\r\n2 0 obj\r\n<</Type/Pages/Count 1/Kids[ 3 0 R] >>\r\nendobj\r\n3 0 obj\r\n<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 9 0 R>>/ExtGState<</GS7 7 0 R/GS8 8 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>\r\nendobj\r\n4 0 obj\r\n<</Filter/FlateDecode/Length 3283>>\r\nstream\r\nx\x9c\xb5\\[O\xdcH\x16~G\xe2?\xd4c{\x97v\\\xbe[BH\x81$\xb3\x8c\x16)+\xc8\x8eF3\xfb`h\x87xc\x1a\xb6\xdb$\xdb\xf9\xf5[\xe7\xd4\xdd\xae\xa2![\x8c\x14\x04n\xb7\xab\xea\\\xbe\xf3\x9d\x8b\x87\xbc\xf9H\x8e\x8f\xdf\\\x9c\x9d\xbf#\xc9\xc9\t9}wF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cW\xe4\xea\x8e\xdd\xf4\xcbe\xb7\xec\x81\xe4\x16\xff\xaa\xc5\uxbf\x1c\x1e\xfc\xb1x\x17-\x9bE\xd7n\xa2e\xb9……)
您必须使用此类概念将此数据保存为PDF文件

""" PDF DATA VAR """
DATA_FROM_FIREBASE=b'%PDF-1.7\r\n%\xb5\xb5\xb5\xbype/Cat ....... '  

pdfFileObj = open('example.pdf', 'wb')     
pdfFileObj.write(DATA_FROM_FIREBASE)    
pdfFileObj.close()

谢谢,它成功了,但是有没有一种方法可以在不创建新文件的情况下这样做,因为我需要处理该数据?n通过这种方法,我从存储中提取数据,然后保存到一个文件,然后调用该文件并处理数据。提前感谢!PyPDF2是最好的选择之一,因为许多帮助/示例都在联机中显示。您可以在中安装using此链接: