Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ebb51e4

Browse files
authoredJan 11, 2021
Merge pull request #92 from TorstenDittmann/master
fix(dotnet): file upload
2 parents 82f9d39 + 46a66a4 commit ebb51e4

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed
 

‎templates/dotnet/src/Appwrite/Client.cs.twig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,17 @@ namespace {{ spec.title | caseUcfirst }}
115115

116116
form.Add(new ByteArrayContent(file, 0, file.Length), "file", fi.Name);
117117
}
118+
else if (parameter.Value is IEnumerable<object>)
119+
{
120+
List<object> list = new List<object>((IEnumerable<object>) parameter.Value);
121+
for (int index = 0; index < list.Count; index++)
122+
{
123+
form.Add(new StringContent(list[index].ToString()), $"{parameter.Key}[{index}]");
124+
}
125+
}
118126
else
119127
{
120-
form.Add(new StringContent(parameter.Key), parameter.Value?.ToString());
128+
form.Add(new StringContent(parameter.Value.ToString()), parameter.Key);
121129
}
122130
}
123131
request.Content = form;

‎tests/SDKTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class SDKTest extends TestCase
7676
'dotnet-5.0' => 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/dotnet/src/test/ mcr.microsoft.com/dotnet/sdk:5.0-alpine pwsh tests.ps1',
7777
'dotnet-3.1' => 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/dotnet/src/test/ mcr.microsoft.com/dotnet/sdk:3.1-alpine pwsh tests.ps1'
7878
],
79-
'supportRedirect' => false,
80-
'supportUpload' => false,
79+
'supportRedirect' => true,
80+
'supportUpload' => true,
8181
],
8282

8383
'typescript' => [

‎tests/languages/dotnet/tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ Print-Response $response
5757

5858
$response = $general.Redirect() | Await-Task
5959
Print-Response $response
60+
61+
$response = $general.Upload("string", 123, $list, (Get-Item "../../../../resources/file.png")) | Await-Task
62+
Print-Response $response

0 commit comments

Comments
 (0)
Please sign in to comment.