File operations
Every disk implements FilesystemAdapter. The same methods work on local, scoped, memory, and S3 disks.
Reading and writing
Section titled “Reading and writing”| Method | Behavior |
|---|---|
put(path, String|ByteArray) |
Create or overwrite |
get / getString |
Bytes or UTF-8 text; null if missing |
exists / missing |
Presence checks |
append / prepend |
Grow a text file at the end or start |
delete |
Remove a file (false if absent) |
copy / move |
Same-disk copy or rename |
Streams
Section titled “Streams”disk.writeStream("big.bin", inputStream)disk.readStream("big.bin")?.use { /* ... */ }putFile / putFileAs copy a java.nio.file.Path onto the disk (unique name or explicit name) and return the stored relative path:
val stored = disk.putFile("photos", Path.of("/tmp/shot.jpg"))val named = disk.putFileAs("photos", Path.of("/tmp/shot.jpg"), "hero.jpg")String stored = disk.putFile("photos", Path.of("/tmp/shot.jpg"));String named = disk.putFileAs("photos", Path.of("/tmp/shot.jpg"), "hero.jpg");Directories
Section titled “Directories”files(dir)— immediate children that are filesallFiles(dir)— recursive file pathsdirectories(dir)/allDirectories(dir)— directory listingsmakeDirectory/deleteDirectory— create or wipe a tree
Metadata
Section titled “Metadata”size/lastModified— bytes and epoch millismimeType— probed from content type / extensionchecksum(path)— SHA-256 hex by default; pass another algorithm name as the second argumentpath— absolute local path orbucket/keyfor S3url— public URL prefix + path
Visibility
Section titled “Visibility”Visibility.PUBLIC and Visibility.PRIVATE mark how a file should be treated for URL generation and cloud ACLs. Use getVisibility / setVisibility after store.