<BlockSwitcher>
<Block name="Java">

```java
import android.util.Log;
import com.amplifyframework.core.Amplify;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
```

```java
private void uploadFile() {
    File exampleFile = new File(getApplicationContext().getFilesDir(), "ExampleKey");

    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(exampleFile));
        writer.append("Example file contents");
        writer.close();
    } catch (Exception exception) {
        Log.e("MyAmplifyApp", "Upload failed", exception);
    }

    Amplify.Storage.uploadFile(
            "ExampleKey",
            exampleFile,
            result -> Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
            storageFailure -> Log.e("MyAmplifyApp", "Upload failed", storageFailure)
    );
}
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
import android.util.Log
import com.amplifyframework.core.Amplify
import java.io.File
```

```kotlin
private fun uploadFile() {
    val exampleFile = File(applicationContext.filesDir, "ExampleKey")
    exampleFile.writeText("Example file contents")

    Amplify.Storage.uploadFile("ExampleKey", exampleFile,
        { Log.i("MyAmplifyApp", "Successfully uploaded: ${it.key}") },
        { Log.e("MyAmplifyApp", "Upload failed", it) }
    )
}
```

</Block>
<Block name="Kotlin - Coroutines">

```kotlin
import android.util.Log
import com.amplifyframework.kotlin.core.Amplify
import com.amplifyframework.storage.StorageException
import java.io.File
```

```kotlin
private suspend fun uploadFile() {
    val exampleFile = File(applicationContext.filesDir, "ExampleKey")
    exampleFile.writeText("Example file contents")

    val upload = Amplify.Storage.uploadFile("ExampleKey", exampleFile)
    try {
        val result = upload.result()
        Log.i("MyAmplifyApp", "Successfully uploaded: ${result.key}")
    } catch (error: StorageException) {
        Log.e("MyAmplifyApp", "Upload failed", error)
    }
}
```

</Block>
<Block name="RxJava">

```java
import android.util.Log;
import com.amplifyframework.rx.RxAmplify;
import com.amplifyframework.rx.RxStorageBinding;
import com.amplifyframework.storage.result.StorageUploadFileResult;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
```

```java
private void uploadFile() {
    File exampleFile = new File(getApplicationContext().getFilesDir(), "ExampleKey");

    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(exampleFile));
        writer.append("Example file contents");
        writer.close();
    } catch (Exception exception) {
        Log.e("MyAmplifyApp", "Upload failed", exception);
    }

    RxProgressAwareSingleOperation<StorageUploadFileResult> upload =
            RxAmplify.Storage.uploadFile("ExampleKey", exampleFile);

    upload
        .observeResult()
        .subscribe(
            result -> Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
            error -> Log.e("MyAmplifyApp", "Upload failed", error)
        );
}
```

</Block>
</BlockSwitcher>
