Getir

How Getir Uploads Files to AWS S3 with Progress - Kotlin

Original post Uploading Files to AWS S3 with Progress - Kotlin

Article Summary

Mehmet Gür from Getir tackles a common Android pain point: uploading files to S3 with real-time progress tracking. His solution avoids the MultipartBody pitfalls that trip up most developers.

This practical guide demonstrates how to upload files to AWS S3 from Android using Kotlin Coroutines and Retrofit2. The article focuses on creating a custom RequestBody implementation that enables accurate progress tracking, a critical feature for user experience that's surprisingly tricky to implement correctly.

Key Takeaways

Critical Insight

A working implementation for S3 file uploads with progress tracking that sidesteps Android's MultipartBody limitations using custom RequestBody and sink wrapping.

Continue reading

What This Article Covers

Problem

Android developers run into MultipartBody errors when uploading files to S3, which breaks uploads and leaves teams like Getir scrambling for workarounds.

Solution

Mehmet Gür built a custom RequestBody class that wraps a CountingSink to track byte writes as they happen. This approach gives real-time progress callbacks without the MultipartBody headaches.

Impact

Developers can now show accurate upload progress by comparing writtenBytes to contentLength and updating a ProgressBar with android:max="100" while files go to S3.

The writeTo() function runs multiple times during upload, which is the key to getting accurate progress values most developers miss.

This page summarizes “Uploading Files to AWS S3 with Progress - Kotlin” by Getir, published Aug 24, 2022. All credit for the original work goes to the authors.

Read the original on medium.com (opens in new tab)

AI tools for Android

Browse all AI tools →