The Files component is an abstraction of file storage with a default implementation using AWS S3. This also provides a much simplified API while making the underlying implementation swappable.


This component is currently stable. Following limitations, current work, planned features apply.

Feature Status Description
Binary In-Progress Ability to store/retrieve binary files. ( you can still use the underlying AWS provider to so )
Names Upcoming Ability to enforce a naming convention on the file names
Async Upcoming Async support via Kotlin suspend/coroutines and Java AWS 2.0 SDK
URI Upcoming Ability to use Slate Kit Uri for explicit references to file paths

Back to top


    repositories {
        // other repositories
        maven { url  "" }

    dependencies {
        // other dependencies ...

        compile 'com.slatekit:slatekit-cloud:1.0.0'

Back to top


Sources slatekit-cloud
Example Example_Cloud_Files.kt
Requires See build.gradle for more info.

Back to top


Refer to Example_Cloud_Files.kt for all imports.

    // Required
    import slatekit.core.files.CloudFiles

    // Optional ( For examples)
    import com.amazonaws.auth.profile.ProfileCredentialsProvider
    import com.amazonaws.regions.Regions

Back to top


    // Setup 1: Use the default aws config file in "{user_dir}/.aws/credentials"
    val files1 = S3(credentials = ProfileCredentialsProvider().credentials,
            region = Regions.US_EAST_1, bucket = "slatekit-unit-tests", createBucket = false)

    // Setup 2: Use the default aws config file in "{user_dir}/.aws/credentials"
    val files2 = S3.of(region = "us-west-2", bucket = "slatekit-unit-tests", createBucket = false)

    // Setup 3: Use the config "{user_id}/myapp/conf/files.conf"
    // Specify the api key section as "files"
     *  files = true
     *  files.key  = AWS_KEY_HERE
     *  files.pass = AWS_PASSWORD_HERE
     *  files.env  = dev
     *  files.tag  = samples
    val files3 = S3.of(region = "us-west-2", bucket = "slatekit-unit-tests", createBucket = false,
            confPath = "~/.slatekit/conf/files.conf", confSection = "files")

    val files:CloudFiles = files2.getOrElse { files1 }

Back to top


    // Use case 1: Creates bucket if configured

    // NOTES: 
    // 1. All operations use the slate kit Result<T,E> type
    // 2. All operations return a slate kit Try<T> = Result<T, Exception>
    // Use case 2: create using just name and content
    val result1:Try<String> = files.create("file-1", "content 1")

    // Use case 3: update using just name and content
    files.update("file-1", "content 2")

    // Use case 4: create using folder and file name
    files.create("folder-1", "file-1", "content 1")

    // Use case 5: update using folder and file name
    files.update("folder-1", "file-1", "content 2")

    // Use case 6: get file as a text using just name

    // Use case 7: get file using folder and file name
    files.getAsText("folder-1", "file-1")

    // Use case 8: download file to local folder"file-1", "~/dev/temp/")

    // Use case 9: download using folder and file name to local folder"folder-1", "file-1", "~/dev/temp")

    // Use case 10: delete file by just the name

    // Use case 11: delete using folder and name
    files.delete("folder-1", "file-1")

Back to top