Skip to content

Commit c7c6883

Browse files
authored
Merge pull request #52 from appwrite/fix-chunk-upload
fix: chunk upload
2 parents 5e3b2fd + 821f710 commit c7c6883

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

Appwrite/Appwrite.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
44
<PackageId>Appwrite</PackageId>
5-
<Version>0.10.0</Version>
5+
<Version>0.10.1</Version>
66
<Authors>Appwrite Team</Authors>
77
<Company>Appwrite Team</Company>
88
<Description>

Appwrite/Client.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Client(
6060
{
6161
_endpoint = endpoint;
6262
_http = http ?? new HttpClient();
63-
63+
6464
_httpForRedirect = httpForRedirect ?? new HttpClient(
6565
new HttpClientHandler(){
6666
AllowAutoRedirect = false
@@ -69,11 +69,11 @@ public Client(
6969
_headers = new Dictionary<string, string>()
7070
{
7171
{ "content-type", "application/json" },
72-
{ "user-agent" , "AppwriteDotNetSDK/0.10.0 (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"},
72+
{ "user-agent" , "AppwriteDotNetSDK/0.10.1 (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"},
7373
{ "x-sdk-name", ".NET" },
7474
{ "x-sdk-platform", "server" },
7575
{ "x-sdk-language", "dotnet" },
76-
{ "x-sdk-version", "0.10.0"},
76+
{ "x-sdk-version", "0.10.1"},
7777
{ "X-Appwrite-Response-Format", "1.6.0" }
7878
};
7979

@@ -252,7 +252,7 @@ private HttpRequestMessage PrepareRequest(
252252

253253
public async Task<String> Redirect(
254254
string method,
255-
string path,
255+
string path,
256256
Dictionary<string, string> headers,
257257
Dictionary<string, object?> parameters)
258258
{
@@ -301,7 +301,7 @@ public async Task<T> Call<T>(
301301
var response = await _http.SendAsync(request);
302302
var code = (int)response.StatusCode;
303303

304-
if (response.Headers.TryGetValues("x-appwrite-warning", out var warnings))
304+
if (response.Headers.TryGetValues("x-appwrite-warning", out var warnings))
305305
{
306306
foreach (var warning in warnings)
307307
{
@@ -408,15 +408,23 @@ public async Task<T> ChunkedUpload<T>(
408408

409409
if (!string.IsNullOrEmpty(idParamName) && (string)parameters[idParamName] != "unique()")
410410
{
411+
try
412+
{
411413
// Make a request to check if a file already exists
412414
var current = await Call<Dictionary<string, object?>>(
413415
method: "GET",
414-
path: "$path/${params[idParamName]}",
415-
headers,
416-
parameters = new Dictionary<string, object?>()
416+
path: $"{path}/{parameters[idParamName]}",
417+
new Dictionary<string, string> { { "content-type", "application/json" } },
418+
parameters: new Dictionary<string, object?>()
417419
);
420+
418421
var chunksUploaded = (long)current["chunksUploaded"];
419422
offset = chunksUploaded * ChunkSize;
423+
}
424+
catch (Exception ex)
425+
{
426+
// ignored as it mostly means file not found
427+
}
420428
}
421429

422430
while (offset < size)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstract and simplif
1717
Add this reference to your project's `.csproj` file:
1818

1919
```xml
20-
<PackageReference Include="Appwrite" Version="0.10.0" />
20+
<PackageReference Include="Appwrite" Version="0.10.1" />
2121
```
2222

2323
You can install packages from the command line:
2424

2525
```powershell
2626
# Package Manager
27-
Install-Package Appwrite -Version 0.10.0
27+
Install-Package Appwrite -Version 0.10.1
2828
2929
# or .NET CLI
30-
dotnet add package Appwrite --version 0.10.0
30+
dotnet add package Appwrite --version 0.10.1
3131
```
3232

3333

0 commit comments

Comments
 (0)