What kind of change does this PR introduce?
Uploading large files on a spotty connection could be tough.
Resumable uploads is not yet supported on Supabase, but we can easily implement retries. This PR adds a retry logic to file uploads in a exponentially backing off manner like the following:
- 400 ms +/- 25%
- 800 ms +/- 25%
- 1,600 ms +/- 25%
- 3,200 ms +/- 25%
- 6,400 ms +/- 25%
- 12,800 ms +/- 25%
- 25,600 ms +/- 25%
- and beyond 30,000 ms +/- 25%
By default, the max attempts is set to 25, which should be roughly 10 minutes. 10 minutes was the default time set for Firebase storage. Users can change the retry count like the following. Not sure if this API would provide the best developer experience, so would love to hear comments/ suggestions about anything regarding this PR!
final uploadTask =
client.from('public').upload('a.txt', file, maxAttempts: 8);
What is the current behavior?
If a file upload fails, it does no retry, which makes is hard to upload large files over a spotty network connection.
What is the new behavior?
File upload is automatically retried on SocketException or TimeoutException.
Additional context
This feature is not supported on JS client, but there was an feedback from customers handling large files. After some internal discussions, we thought it would make make sense to add this feature to the Flutter SDK.