cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How do I get files into /FileStore to be accessed with /files from within my notebooks?

cfregly
Contributor
 
3 REPLIES 3

cfregly
Contributor

For context, DBFS exposes a special location called

/FileStore
as follows:

display(dbutils.fs.ls("/FileStore"))

This location can be accessed by HTML, JavaScript, and CSS at its equivalent

/files
as follows:

<script src="/files/..."/> 

In order to get assets into

dbfs:/FileStore
, you can first copy it locally from a url as follows:

import sys.process._ 
"wget -P /tmp http://d3js.org/d3.v2.min.js"; !!

You can verify that this file was downloaded as follows:

display(dbutils.fs.ls("file:/tmp/d3.v2.min.js"))

Using

file:/
with DBFS accesses the local filesystem.

Then use dbutils to copy the local file into the mount as follows:

dbutils.fs.mkdirs("/FileStore/customjs") 
dbutils.fs.cp("file:/tmp/d3.v2.min.js", "/FileStore/customjs/d3.v2.min.js")

You can verify that the file was copied as follows:

display(dbutils.fs.ls("/FileStore/customjs"))

This newly-downloaded JavaScript file can now be accessed from HTML as follows:

<script src="/files/customjs/d3.vs.min.js"/>

nick1868
New Contributor II

One follow on question. Is it possible to make a resource public.

I am generating a html file which I would like to be available to anyone. Is it possible to "publish" this html page like I have published a dashboard. I can access it when I log into my databricks account but I would like a public URL with no login required.

easimadi
New Contributor II

Hello Pls help (Not an Answer),

How do I download complete csv (>1000) result file in FileStore unto my laptop?

I was trying to follow this instruction set SQL tutorial (Download All SQL - scala)

0693f000007OrmnAAC

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.