Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2016 08:51 PM
@Deepak Chokkadi
This is the function that I use:
def mountBucket(dstBucketName:String, dstMountName:String) {
import java.lang.IllegalArgumentException
val accessKey = "YOUR ACCESS KEY"
val encodedSecretKey = "YOUR SECRET".replace("/", "%2F")
try {
dbutils.fs.mount(s"s3a://$accessKey:$encodedSecretKey@$dstBucketName", dstMountName)
println("All done!")
} catch {
case e: java.rmi.RemoteException => {
println("Directory is Already Mounted")
dbutils.fs.unmount(dstMountName)
mountBucket(dstBucketName, dstMountName)
}
case e: Exception => {
println("There was some other error")
}
}
}
I've put it in a simple accessible notebook, then just run that notebook using %run. Then to mount a bucket I use that function and it automatically remount it.