Skip to content

Files of 2Mb or more are not put with s3 #1666

@andrey-ananiev

Description

@andrey-ananiev

Describe the bug

I use this library in Android project. Everything works fine, but if I try to upload a file larger than 2MB, the file fails to send with an HttpException: java.net.SocketTimeoutException: timeout

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected behavior

File must uploaded successfully.

Current behavior

I get HttpException java.net.SocketTimeoutException: timeout

Steps to Reproduce

Dependencies:

implementation("aws.sdk.kotlin:s3:1.5.19")

Initializing the s3 client:

val s3Client = S3Client {
            endpointUrl = Url.parse(YandexCloudConfig.host)
            region = YandexCloudConfig.regionName
            credentialsProvider = StaticCredentialsProvider {
                accessKeyId = YandexCloudConfig.idKey
                secretAccessKey = YandexCloudConfig.secretKey
            }
        }

File data loading function:

private suspend fun uploadSimple(
        fileName: String,
        data: ByteArray,
        userEmail: String
    ): Boolean {
        return runCatching {
            s3Client.putObject(PutObjectRequest {
                bucket = YandexCloudConfig.bucketName
                key = "$userEmail/$fileName"
                body = ByteStream.fromBytes(data)
                contentType = "application/octet-stream"
                storageClass = StorageClass.Standard
                acl = ObjectCannedAcl.Private
            })
            Logger.i("File $fileName (${data.size} bytes) uploaded successfully to $userEmail")
            true
        }.onFailure { e ->
            handleUploadError(fileName, userEmail, e, "Simple upload failed")
        }.getOrDefault(false)
    }

Possible Solution

I tried to configure httpEngine but it has no limit on the upload file size. Files of (2MB - 1B) size are uploaded perfectly. I don't understand why larger files don't upload. I was unable to replace the engine.

Context

No response

AWS SDK for Kotlin version

1.5.19

Platform (JVM/JS/Native)

Android

Operating system and version

Android 14

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.response-requestedWaiting on additional info and feedback. Will move to 'closing-soon' in 5 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions