Take a look at SparkContext.addFile ()
Add a file to be uploaded using this Spark job on each node. The path covered can be either a local file, or a file in HDFS (or other Hadoop-supported file systems), or HTTP, HTTPS, or FTP URI. To access a file in Spark jobs, use SparkFiles.get (file_name) to find its location to download.
If the recursive parameter is set to true, a directory may be specified. Directories are currently only supported for Hadoop-supported file systems.
source share