diff --git a/Appwrite/Appwrite.csproj b/Appwrite/Appwrite.csproj index 4cbeae6..513bd77 100644 --- a/Appwrite/Appwrite.csproj +++ b/Appwrite/Appwrite.csproj @@ -2,7 +2,7 @@ netstandard2.0;net461 Appwrite - 0.10.0 + 0.10.1 Appwrite Team Appwrite Team diff --git a/Appwrite/Client.cs b/Appwrite/Client.cs index 54fa158..3697d7b 100644 --- a/Appwrite/Client.cs +++ b/Appwrite/Client.cs @@ -60,7 +60,7 @@ public Client( { _endpoint = endpoint; _http = http ?? new HttpClient(); - + _httpForRedirect = httpForRedirect ?? new HttpClient( new HttpClientHandler(){ AllowAutoRedirect = false @@ -69,11 +69,11 @@ public Client( _headers = new Dictionary() { { "content-type", "application/json" }, - { "user-agent" , "AppwriteDotNetSDK/0.10.0 (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"}, + { "user-agent" , "AppwriteDotNetSDK/0.10.1 (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"}, { "x-sdk-name", ".NET" }, { "x-sdk-platform", "server" }, { "x-sdk-language", "dotnet" }, - { "x-sdk-version", "0.10.0"}, + { "x-sdk-version", "0.10.1"}, { "X-Appwrite-Response-Format", "1.6.0" } }; @@ -252,7 +252,7 @@ private HttpRequestMessage PrepareRequest( public async Task Redirect( string method, - string path, + string path, Dictionary headers, Dictionary parameters) { @@ -301,7 +301,7 @@ public async Task Call( var response = await _http.SendAsync(request); var code = (int)response.StatusCode; - if (response.Headers.TryGetValues("x-appwrite-warning", out var warnings)) + if (response.Headers.TryGetValues("x-appwrite-warning", out var warnings)) { foreach (var warning in warnings) { @@ -408,15 +408,23 @@ public async Task ChunkedUpload( if (!string.IsNullOrEmpty(idParamName) && (string)parameters[idParamName] != "unique()") { + try + { // Make a request to check if a file already exists var current = await Call>( method: "GET", - path: "$path/${params[idParamName]}", - headers, - parameters = new Dictionary() + path: $"{path}/{parameters[idParamName]}", + new Dictionary { { "content-type", "application/json" } }, + parameters: new Dictionary() ); + var chunksUploaded = (long)current["chunksUploaded"]; offset = chunksUploaded * ChunkSize; + } + catch (Exception ex) + { + // ignored as it mostly means file not found + } } while (offset < size) diff --git a/README.md b/README.md index 98d9234..200aa76 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstract and simplif Add this reference to your project's `.csproj` file: ```xml - + ``` You can install packages from the command line: ```powershell # Package Manager -Install-Package Appwrite -Version 0.10.0 +Install-Package Appwrite -Version 0.10.1 # or .NET CLI -dotnet add package Appwrite --version 0.10.0 +dotnet add package Appwrite --version 0.10.1 ```