supabase-community / storage-csharp

A C# implementation of Supabase's Object Storage API
https://supabase-community.github.io/storage-csharp/api/Supabase.Storage.Client.html
MIT License
19 stars 7 forks source link

Error when uploading file bigger than 5GB #14

Open Kurounin opened 7 months ago

Kurounin commented 7 months ago

Bug report

Describe the bug

When uploading a file which is bigger than 5GB, on the Pro Plan with a global limit of 20GB the following error is returned:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
 at Newtonsoft.Json.JsonTextReader.ParseValue()
 at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
 at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
 at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
 at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
 at Supabase.Storage.Extensions.HttpClientProgress.UploadAsync(HttpClient client, Uri uri, Stream stream, Dictionary`2 headers, Progress`1 progress)
 at Supabase.Storage.StorageFileApi.UploadOrUpdate(String localPath, String supabasePath, FileOptions options, EventHandler`1 onProgress)
 at Supabase.Storage.StorageFileApi.Upload(String localFilePath, String supabasePath, FileOptions options, EventHandler`1 onProgress, Boolean inferContentType) 

This is triggered because the response is not a json but a 413 error from Cloudflare:

<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>cloudflare</center>
</body>
</html> 

System information

acupofjose commented 7 months ago

This is because our supabase-storage client hasn't yet implemented the TUS protocol like the JS client has (see here: https://dev.to/supabase/supabase-storage-v3-resumable-uploads-with-support-for-50gb-files-2egd). I'll need to look into what that entails. Always open to PRs if you're interested!

acupofjose commented 6 months ago

I'm going to see about replacing our HttpClient implementation with the following package: https://github.com/bluetianx/BirdMessenger - which should clear this issue up and add some additional functionality!