Skip to content

Commit a84afe1

Browse files
committed
Use multipart HTTP request
1 parent 6e0cdb8 commit a84afe1

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

HttpApiUploadPlugin/HttpApiUploadStorage.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ public override async Task<StorageSaveResult> SaveImage(byte[] data, string shot
3030
return new StorageSaveResult(SavingResultCode.RequiresOptionsSetup, "API URL has to be set");
3131
}
3232

33-
var values = new Dictionary<string, string>
34-
{
35-
{"dataurl", GetDataURL(data, shotName)}
36-
};
37-
3833
try
3934
{
4035
using (var client = new HttpClient())
4136
{
42-
var content = new FormUrlEncodedContent(values);
37+
var content = new MultipartFormDataContent()
38+
{
39+
{ new StringContent(GetDataURL(data, shotName)), "dataurl" }
40+
};
41+
4342
client.DefaultRequestHeaders.Accept.Clear();
4443
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
4544

HttpApiUploadPlugin/SettingsControl.designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HttpApiUploadPlugin/SettingsControl.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<value>17, 22</value>
122122
</metadata>
123123
<data name="helpTextLabel.Text" xml:space="preserve">
124-
<value>This plugin sends HTTP POST request to the specified URL.
124+
<value>This plugin sends HTTP multipart POST request to the specified URL.
125125
The only field is "dataurl" with Base64 encoded image contents.
126126
Accept of the request is "text/plain".
127127

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Built on [example plugin](https://github.com/name1ess0ne/CloudShot.Plugins/tree/
1414

1515
## API expectations
1616

17-
This plugin sends a simple form-data HTTP POST request to the URL specified in plugin settings.
17+
This plugin sends a simple multipart HTTP POST request to the URL specified in plugin settings.
1818
The only field in the request is `dataurl` with Base64-encoded image contents.
1919
Accept header of the request is `text/plain`.
2020

0 commit comments

Comments
 (0)