将PDF文件从Databricks笔记本写入Azure Blob存储

h9a6wy2h  于 7个月前  发布在  其他
关注(0)|答案(1)|浏览(86)

我正在将链接中的PDF保存到Azure Blob存储容器中的文件夹。是否可以从数据砖执行此操作?
只是一些出于隐私原因的虚拟代码:

testurl = 'https://www.testwebsite.com/test123.pdf'
response = requests.get(testurl)

with open('wasbs://[email protected]/Test Folder/Test.pdf','wb') as f:
    f.write(response.content)

字符串
我在运行时得到一个错误[Errno 2] No such file or directory

qq24tv8q

qq24tv8q1#

您可以使用fsspec连接到azure blob存储。
安装下面的包。
pip install fsspec adlfs
在代码下面运行。

import fsspec
import requests

testurl = "https://www.africau.edu/images/default/sample.pdf"
response = requests.get(testurl)

with fsspec.open('abfs://data/pdfs/sample.pdf', account_name=storage_account_name, account_key=storage_account_key,mode='wb') as f:
    f.write(response.content)

字符串
在这里,您需要给予如下路径。
abfs://<container_name>/path_to_file
输出量:


的数据

相关问题