s3-klient
0.0.1indexedSeamlessly uploads files to AWS S3 using a unified API. Features efficient uploads with AWS S3 Transfer Utility and easy coroutine-based operations with suspend functions.
2
Stars
—
Used by
dependents
—
Health
/ 100
Seamlessly uploads files to AWS S3 using a unified API. Features efficient uploads with AWS S3 Transfer Utility and easy coroutine-based operations with suspend functions.
S3Klient is a Kotlin Multiplatform (KMP) library that allows seamless file uploads to AWS S3 on * Android* and iOS. It utilizes the AWS SDK for both platforms, ensuring a unified API for file uploads. using each platform native sdk from Amazon
build.gradle.kts)commonMain.dependencies {
implementation("io.github.mohaberabi:s3-klient:0.0.1")
}
Since S3Klient uses CocoaPods AWS SDK, the client must also include AWS dependencies.
Run in the iosApp directory:
pod init
iosApp/PodfileAdd AWS SDK dependencies to the Podfile:
target 'iosApp' do
use_frameworks!
pod 'AWSS3', '2.31.0' # ✅ Add AWS S3 SDK
pod 'AWSCore', '2.31.0' # ✅ Add AWS Core SDK
end
cd iosApp
pod install --repo-update
iosApp.xcworkspace in XcodeLink Binary With LibrariesAWSCore.frameworkAWSS3.frameworkS3Klient Instanceval s3Klient: S3Klient = AndroidS3KlientFactory(
context, S3KlientCredentials(
cognitoIdentityId = "YOUR_COGNITO_IDENTITY_ID",
cognitoRegion = CognitoRegion.US_EAST_1
)
).create()
val s3Klient: S3Klient = IosS3KlientFactory(
S3KlientCredentials(
cognitoIdentityId = "YOUR_COGNITO_IDENTITY_ID",
cognitoRegion = CognitoRegion.US_EAST_1
)
).create()
val result: UploadFileResult = s3Klient.uploadFile(
AwsFileUploadRequest(
filePath = "/path/to/your/file",
bucket = "your-bucket-name",
contentType = "image/png"
)
)
when (result) {
is UploadFileResult.Uploaded -> println("✅ File uploaded: ${result.path}")
is UploadFileResult.Canceled -> println("⚠ Upload canceled: ${result.message}")
is UploadFileResult.DidNotComplete -> println("Upload failed: ${result.message}")
is UploadFileResult.Error -> println("Error: ${result.message}")
UploadFileResult.Unknown -> println("Unknown status")
}
S3Klient Interfaceinterface S3Klient {
suspend fun uploadFile(request: AwsFileUploadRequest): UploadFileResult
}
AndroidS3Klient)class AndroidS3Klient(
private val context: Context,
private val credentials: S3KlientCredentials
) : S3Klient {
override suspend fun uploadFile(request: AwsFileUploadRequest): UploadFileResult {
}
}
IosS3Klient)class IosS3Klient(
private val credentials: S3KlientCredentials
) : S3Klient {
override suspend fun uploadFile(request: AwsFileUploadRequest): UploadFileResult {
}
}
Surfaced from shared tags and platforms — no rankings paid for.