Downloading and storing a PDF file to FileStore not working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 03:47 AM
I'm trying to download a PDF file and store it in FileStore using this code in a Notebook:
with open('/dbfs/FileStore/file.pdf', 'wb') as f:
f.write(requests.get('https://url.com/file.pdf').content)
But I'm getting this error:
FileNotFoundError: [Errno 2] No such file or directory
What am I doing wrong?
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 06:09 AM
Might be easier to use curl commnad .. in a notebook you can run as shell command or python to first load the file into local driver temp storage
%sh curl https://url.com/file.pdf --output /tmp/file.pdf
or in python
import urllib urllib.request.urlretrieve("https://url.com/file.pdf", "/tmp/file.pdf.csv")
Then move the file to DBFS
dbutils.fs.mv("file:/tmp/file.pdf", "dbfs:/Filestore/file.pdf
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 07:14 AM
This worked, thanks.

