App

Overview

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.

Status

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



Install

    repositories {
        // other repositories
        maven { url  "http://dl.bintray.com/codehelixinc/slatekit" }
    }

    dependencies {
        // other dependencies ...

        compile 'com.slatekit:slatekit-cloud:1.0.0'
    }
package slatekit.cloud
jar slatekit.cloud.jar
git slatekit/src/lib/kotlin/slatekit-cloud
docs Files
uses slatekit.results, slatekit.core, slatekit.cloud
license Apache 2.0
example Example_Cloud_Files.kt

Back to top



Requires

This component uses the following other Slate Kit and/or third-party components.

Component Description
Results To model successes and failures with optional status codes
Utils Common utilities for both android + server

Back to top



Imports

        
    import slatekit.cloud.aws.AwsCloudFiles
    

Back to top



Setup

        
    // Not storing any key/secret in source code for security purposes
    // Setup 1: Use the default aws config file in "{user_dir}/.aws/credentials"
    val files1 = AwsCloudFiles("app1-files-1", "slatekit", false)

    // Setup 2: Use the type safe config in "{user_id}/myapp/conf/files.conf"
    // Specify the api key section as "sqs"
    val files2 = AwsCloudFiles("app1-files-1", "slatekit",false, "user://myapp/conf/files.conf", "s3")

    // Setup 2: Use the type safe config in "{user_id}/myapp/conf/files.conf"
    // Specify the api key section as "sqs"
    val files3 = AwsCloudFiles("app1-files-1", "slatekit",false, "user://myapp/conf/files.conf", "s3-1")

Back to top



Usage

        
    // Use case 1: Connect using parameters
    files1.init()

    // Use case 2: create using just name and content
    files1.create("file-1", "content 1")

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

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

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

    // Use case 6: get file as a text using just name
    files1.getAsText("file-1")

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

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

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

    // Use case 10: delete file by just the name
    files1.delete("file-1")

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

Back to top