Skip to content

Commit

Permalink
Use multipart HTTP request
Browse files Browse the repository at this point in the history
  • Loading branch information
finwe committed Mar 1, 2021
1 parent 6e0cdb8 commit a84afe1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions HttpApiUploadPlugin/HttpApiUploadStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ public override async Task<StorageSaveResult> SaveImage(byte[] data, string shot
return new StorageSaveResult(SavingResultCode.RequiresOptionsSetup, "API URL has to be set");
}

var values = new Dictionary<string, string>
{
{"dataurl", GetDataURL(data, shotName)}
};

try
{
using (var client = new HttpClient())
{
var content = new FormUrlEncodedContent(values);
var content = new MultipartFormDataContent()
{
{ new StringContent(GetDataURL(data, shotName)), "dataurl" }
};

client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));

Expand Down
2 changes: 1 addition & 1 deletion HttpApiUploadPlugin/SettingsControl.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion HttpApiUploadPlugin/SettingsControl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<value>17, 22</value>
</metadata>
<data name="helpTextLabel.Text" xml:space="preserve">
<value>This plugin sends HTTP POST request to the specified URL.
<value>This plugin sends HTTP multipart POST request to the specified URL.
The only field is "dataurl" with Base64 encoded image contents.
Accept of the request is "text/plain".

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Built on [example plugin](https://github.com/name1ess0ne/CloudShot.Plugins/tree/

## API expectations

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

Expand Down

0 comments on commit a84afe1

Please sign in to comment.