Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2015 05:27 PM
For context, DBFS exposes a special location called
/FileStoreas follows:display(dbutils.fs.ls("/FileStore"))This location can be accessed by HTML, JavaScript, and CSS at its equivalent
/filesas 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"/>