cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading and storing a PDF file to FileStore not working

msa_2j212
New Contributor II

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

Brian2
New Contributor III

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 

 

msa_2j212
New Contributor II

This worked, thanks. 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now