我需要从 azure 中的 blob 容器下载 PDF 作为下载流 (StorageStreamDownloader) 并在 PDFPlumber 和 PDFminer 中打开它。我开发了将它们作为文件加载的所有要求,但我无法收到下载流(StorageStreamDownloader)并成功打开它。我是这样打开PDF的:
pdf = pdfplumber.open(pdfpath) //for pdfplumber
fp = open('Pdf/' + fileGlob, 'rb') // for pdfminer
parser = PDFParser(fp)
document = PDFDocument(parser)
Run Code Online (Sandbox Code Playgroud)
但是,我需要能够下载流。将 pdf 作为文件下载的代码片段:
blob_client = container.get_blob_client(remote_file)
with open(local_file_path,"wb") as local_file:
download_stream = blob_client.download_blob()
local_file.write(download_stream.readall())
local_file.close()
Run Code Online (Sandbox Code Playgroud)
我尝试了几个选项,甚至使用了一个没有运气的临时文件。有任何想法吗?