mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Changed few functions parameter orders
This commit is contained in:
parent
65917c8ede
commit
b6f07906b5
17 changed files with 47 additions and 46 deletions
|
@ -195,7 +195,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("parent_id", FolderID);
|
args.Add("parent_id", FolderID);
|
||||||
|
|
||||||
UploadResult result = UploadData(stream, "https://upload.box.com/api/2.0/files/content", fileName, "filename", args, headers: GetAuthHeaders());
|
UploadResult result = UploadData(stream, "https://upload.box.com/api/2.0/files/content", fileName, "filename", args, GetAuthHeaders());
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,7 @@ public CopyAccountInfo GetAccountInfo()
|
||||||
{
|
{
|
||||||
string query = OAuthManager.GenerateQuery(URLAccountInfo, null, HttpMethod.GET, AuthInfo);
|
string query = OAuthManager.GenerateQuery(URLAccountInfo, null, HttpMethod.GET, AuthInfo);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.GET, query, null, ResponseType.Text, APIHeaders);
|
string response = SendRequest(HttpMethod.GET, query, null, APIHeaders, responseType: ResponseType.Text);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -143,7 +143,7 @@ public UploadResult UploadFile(Stream stream, string path, string fileName)
|
||||||
string query = OAuthManager.GenerateQuery(url, args, HttpMethod.POST, AuthInfo);
|
string query = OAuthManager.GenerateQuery(url, args, HttpMethod.POST, AuthInfo);
|
||||||
|
|
||||||
// There's a 1GB and 5 hour(max time for a single upload) limit to all uploads through the API.
|
// There's a 1GB and 5 hour(max time for a single upload) limit to all uploads through the API.
|
||||||
UploadResult result = UploadData(stream, query, fileName, "file", null, null, APIHeaders);
|
UploadResult result = UploadData(stream, query, fileName, "file", headers: APIHeaders);
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -216,7 +216,7 @@ public DropboxContentInfo GetMetadata(string path, bool list)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("list", list ? "true" : "false");
|
args.Add("list", list ? "true" : "false");
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.GET, url, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.GET, url, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,7 @@ public string CreateShareableLink(string path, DropboxURLType urlType)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false");
|
args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false");
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, url, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, url, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -287,7 +287,7 @@ public DropboxContentInfo Copy(string from_path, string to_path)
|
||||||
args.Add("from_path", from_path);
|
args.Add("from_path", from_path);
|
||||||
args.Add("to_path", to_path);
|
args.Add("to_path", to_path);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLCopy, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLCopy, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -309,7 +309,7 @@ public DropboxContentInfo CreateFolder(string path)
|
||||||
args.Add("root", Root);
|
args.Add("root", Root);
|
||||||
args.Add("path", path);
|
args.Add("path", path);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLCreateFolder, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLCreateFolder, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -331,7 +331,7 @@ public DropboxContentInfo Delete(string path)
|
||||||
args.Add("root", Root);
|
args.Add("root", Root);
|
||||||
args.Add("path", path);
|
args.Add("path", path);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLDelete, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLDelete, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -354,7 +354,7 @@ public DropboxContentInfo Move(string from_path, string to_path)
|
||||||
args.Add("from_path", from_path);
|
args.Add("from_path", from_path);
|
||||||
args.Add("to_path", to_path);
|
args.Add("to_path", to_path);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLMove, args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLMove, args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,7 +161,7 @@ private void SetMetadata(string fileID, string title, string parentID = null)
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(metadata);
|
string json = JsonConvert.SerializeObject(metadata);
|
||||||
|
|
||||||
string response = SendRequestJSON(url, json, headers: GetAuthHeaders(), method: HttpMethod.PUT);
|
string response = SendRequestJSON(url, json, GetAuthHeaders(), method: HttpMethod.PUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPermissions(string fileID, GoogleDrivePermissionRole role, GoogleDrivePermissionType type, string value, bool withLink)
|
private void SetPermissions(string fileID, GoogleDrivePermissionRole role, GoogleDrivePermissionType type, string value, bool withLink)
|
||||||
|
@ -176,7 +176,7 @@ private void SetPermissions(string fileID, GoogleDrivePermissionRole role, Googl
|
||||||
withLink = withLink.ToString()
|
withLink = withLink.ToString()
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequestJSON(url, json, headers: GetAuthHeaders());
|
string response = SendRequestJSON(url, json, GetAuthHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true)
|
public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true)
|
||||||
|
@ -198,7 +198,7 @@ public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("q", query);
|
args.Add("q", query);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.GET, "https://www.googleapis.com/drive/v2/files", args, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.GET, "https://www.googleapis.com/drive/v2/files", args, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
{
|
{
|
||||||
if (!CheckAuthorization()) return null;
|
if (!CheckAuthorization()) return null;
|
||||||
|
|
||||||
UploadResult result = UploadData(stream, "https://www.googleapis.com/upload/drive/v2/files", fileName, "file", headers: GetAuthHeaders());
|
UploadResult result = UploadData(stream, "https://www.googleapis.com/upload/drive/v2/files", fileName, headers: GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Response))
|
if (!string.IsNullOrEmpty(result.Response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password))
|
if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password))
|
||||||
{
|
{
|
||||||
NameValueCollection headers = CreateAuthenticationHeader(Email, Password);
|
NameValueCollection headers = CreateAuthenticationHeader(Email, Password);
|
||||||
result = UploadData(stream, "https://api.hostr.co/file", fileName, "file", null, null, headers);
|
result = UploadData(stream, "https://api.hostr.co/file", fileName, headers: headers);
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -216,7 +216,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
NameValueCollection headers = new NameValueCollection();
|
NameValueCollection headers = new NameValueCollection();
|
||||||
headers.Set("X-Atlassian-Token", "nocheck");
|
headers.Set("X-Atlassian-Token", "nocheck");
|
||||||
|
|
||||||
UploadResult res = UploadData(stream, query, fileName, "file", null, null, headers);
|
UploadResult res = UploadData(stream, query, fileName, headers: headers);
|
||||||
if (res.Response.Contains("errorMessages"))
|
if (res.Response.Contains("errorMessages"))
|
||||||
{
|
{
|
||||||
res.Errors.Add(res.Response);
|
res.Errors.Add(res.Response);
|
||||||
|
|
|
@ -60,7 +60,7 @@ public string ShareFile(string path)
|
||||||
|
|
||||||
string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares");
|
string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares");
|
||||||
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
|
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
|
||||||
string response = SendRequest(HttpMethod.GET, url, args, headers: headers);
|
string response = SendRequest(HttpMethod.GET, url, args, headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ public UploadResult PushFile(Stream stream, string fileName)
|
||||||
args.Add("device_iden", Config.CurrentDevice.Key);
|
args.Add("device_iden", Config.CurrentDevice.Key);
|
||||||
args.Add("type", "file");
|
args.Add("type", "file");
|
||||||
|
|
||||||
UploadResult result = UploadData(stream, "https://api.pushbullet.com/api/pushes", fileName, arguments: args, headers: headers);
|
UploadResult result = UploadData(stream, "https://api.pushbullet.com/api/pushes", fileName, "file", args, headers);
|
||||||
|
|
||||||
PushbulletResponsePush push = JsonConvert.DeserializeObject<PushbulletResponsePush>(result.Response);
|
PushbulletResponsePush push = JsonConvert.DeserializeObject<PushbulletResponsePush>(result.Response);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ private string Push(string pushType, string valueType, string value, string titl
|
||||||
args.Add("title", title);
|
args.Add("title", title);
|
||||||
args.Add(valueType, value);
|
args.Add(valueType, value);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, "https://api.pushbullet.com/api/pushes", args, headers: headers);
|
string response = SendRequest(HttpMethod.POST, "https://api.pushbullet.com/api/pushes", args, headers);
|
||||||
|
|
||||||
PushbulletResponsePush push = JsonConvert.DeserializeObject<PushbulletResponsePush>(response);
|
PushbulletResponsePush push = JsonConvert.DeserializeObject<PushbulletResponsePush>(response);
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
headers.Add("Authorization", "Client-ID " + AuthInfo.Client_ID);
|
headers.Add("Authorization", "Client-ID " + AuthInfo.Client_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadResult result = UploadData(stream, "https://api.imgur.com/3/image", fileName, "image", args, headers: headers);
|
UploadResult result = UploadData(stream, "https://api.imgur.com/3/image", fileName, "image", args, headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Response))
|
if (!string.IsNullOrEmpty(result.Response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -180,7 +180,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
NameValueCollection headers = GetAuthHeaders();
|
NameValueCollection headers = GetAuthHeaders();
|
||||||
headers.Add("Slug", URLHelpers.URLEncode(fileName));
|
headers.Add("Slug", URLHelpers.URLEncode(fileName));
|
||||||
|
|
||||||
ur.Response = SendRequestStream(url, stream, contentType, headers: headers);
|
ur.Response = SendRequestStream(url, stream, contentType, headers);
|
||||||
|
|
||||||
XDocument xd = XDocument.Parse(ur.Response);
|
XDocument xd = XDocument.Parse(ur.Response);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(customUploader.FileFormName))
|
if (string.IsNullOrEmpty(customUploader.FileFormName))
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(HttpMethod.POST, customUploader.RequestURL, args, customUploader.ResponseType);
|
result.Response = SendRequest(HttpMethod.POST, customUploader.RequestURL, args, responseType: customUploader.ResponseType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
}
|
}
|
||||||
else if (customUploader.RequestType == CustomUploaderRequestType.GET)
|
else if (customUploader.RequestType == CustomUploaderRequestType.GET)
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(HttpMethod.GET, customUploader.RequestURL, args, customUploader.ResponseType);
|
result.Response = SendRequest(HttpMethod.GET, customUploader.RequestURL, args, responseType: customUploader.ResponseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
customUploader.ParseResponse(result);
|
customUploader.ParseResponse(result);
|
||||||
|
|
|
@ -76,7 +76,7 @@ public bool GetAccessToken(string code)
|
||||||
WebHeaderCollection headers = new WebHeaderCollection();
|
WebHeaderCollection headers = new WebHeaderCollection();
|
||||||
headers.Add("Accept", "application/json");
|
headers.Add("Accept", "application/json");
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, "https://github.com/login/oauth/access_token", args, headers: headers);
|
string response = SendRequest(HttpMethod.POST, "https://github.com/login/oauth/access_token", args, headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
arguments.Add("lang", settings.TextFormat);
|
arguments.Add("lang", settings.TextFormat);
|
||||||
arguments.Add("parent", "0");
|
arguments.Add("parent", "0");
|
||||||
|
|
||||||
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, ResponseType.RedirectionURL);
|
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, responseType: ResponseType.RedirectionURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ur;
|
return ur;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
arguments.Add("key", Key);
|
arguments.Add("key", Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
ur.URL = SendRequest(HttpMethod.POST, "https://pastee.org/submit", arguments, ResponseType.RedirectionURL);
|
ur.URL = SendRequest(HttpMethod.POST, "https://pastee.org/submit", arguments, responseType: ResponseType.RedirectionURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ur;
|
return ur;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
arguments.Add("tabbing", "true");
|
arguments.Add("tabbing", "true");
|
||||||
arguments.Add("tabtype", "real");
|
arguments.Add("tabtype", "real");
|
||||||
|
|
||||||
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, ResponseType.RedirectionURL);
|
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, responseType: ResponseType.RedirectionURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ur;
|
return ur;
|
||||||
|
|
|
@ -54,11 +54,11 @@ public override UploadResult ShortenURL(string url)
|
||||||
|
|
||||||
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(HttpMethod.POST, customUploader.RequestURL, args, customUploader.ResponseType);
|
result.Response = SendRequest(HttpMethod.POST, customUploader.RequestURL, args, responseType: customUploader.ResponseType);
|
||||||
}
|
}
|
||||||
else if (customUploader.RequestType == CustomUploaderRequestType.GET)
|
else if (customUploader.RequestType == CustomUploaderRequestType.GET)
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(HttpMethod.GET, customUploader.RequestURL, args, customUploader.ResponseType);
|
result.Response = SendRequest(HttpMethod.GET, customUploader.RequestURL, args, responseType: customUploader.ResponseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
customUploader.ParseResponse(result, true);
|
customUploader.ParseResponse(result, true);
|
||||||
|
|
|
@ -114,8 +114,8 @@ public virtual void StopUpload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string SendRequest(HttpMethod method, string url, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
|
protected string SendRequest(HttpMethod method, string url, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||||
{
|
{
|
||||||
HttpWebResponse response = null;
|
HttpWebResponse response = null;
|
||||||
|
|
||||||
|
@ -141,20 +141,20 @@ protected string SendRequest(HttpMethod method, string url, Dictionary<string, s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string SendRequest(HttpMethod method, string url, string content, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
|
protected string SendRequest(HttpMethod method, string url, string content, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||||
{
|
{
|
||||||
byte[] data = Encoding.UTF8.GetBytes(content);
|
byte[] data = Encoding.UTF8.GetBytes(content);
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
ms.Write(data, 0, data.Length);
|
ms.Write(data, 0, data.Length);
|
||||||
return SendRequest(method, url, ms, arguments, responseType, headers, cookies);
|
return SendRequest(method, url, ms, arguments, headers, cookies, responseType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string SendRequest(HttpMethod method, string url, Stream content, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
|
protected string SendRequest(HttpMethod method, string url, Stream content, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||||
{
|
{
|
||||||
using (HttpWebResponse response = GetResponse(method, url, arguments, headers, cookies, content))
|
using (HttpWebResponse response = GetResponse(method, url, arguments, headers, cookies, content))
|
||||||
{
|
{
|
||||||
|
@ -219,7 +219,7 @@ private HttpWebResponse GetResponse(HttpMethod method, string url, Dictionary<st
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string SendRequestJSON(string url, string json, CookieCollection cookies = null, NameValueCollection headers = null, HttpMethod method = HttpMethod.POST)
|
protected string SendRequestJSON(string url, string json, NameValueCollection headers = null, CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
||||||
{
|
{
|
||||||
byte[] data = Encoding.UTF8.GetBytes(json);
|
byte[] data = Encoding.UTF8.GetBytes(json);
|
||||||
|
|
||||||
|
@ -227,19 +227,21 @@ protected string SendRequestJSON(string url, string json, CookieCollection cooki
|
||||||
{
|
{
|
||||||
stream.Write(data, 0, data.Length);
|
stream.Write(data, 0, data.Length);
|
||||||
|
|
||||||
return SendRequestStream(url, stream, "application/json", cookies, headers, method);
|
return SendRequestStream(url, stream, "application/json", headers, cookies, method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string SendRequestStream(string url, Stream stream, string contentType, CookieCollection cookies = null, NameValueCollection headers = null, HttpMethod method = HttpMethod.POST)
|
protected string SendRequestStream(string url, Stream stream, string contentType, NameValueCollection headers = null,
|
||||||
|
CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
||||||
{
|
{
|
||||||
using (HttpWebResponse response = GetResponse(url, stream, null, contentType, cookies, headers, method))
|
using (HttpWebResponse response = GetResponse(url, stream, null, contentType, headers, cookies, method))
|
||||||
{
|
{
|
||||||
return ResponseToString(response);
|
return ResponseToString(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, string> arguments, NameValueCollection headers = null, CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, string> arguments, NameValueCollection headers = null,
|
||||||
|
CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
||||||
{
|
{
|
||||||
string boundary = CreateBoundary();
|
string boundary = CreateBoundary();
|
||||||
byte[] data = MakeInputContent(boundary, arguments);
|
byte[] data = MakeInputContent(boundary, arguments);
|
||||||
|
@ -247,12 +249,12 @@ private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, stri
|
||||||
using (MemoryStream stream = new MemoryStream())
|
using (MemoryStream stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
stream.Write(data, 0, data.Length);
|
stream.Write(data, 0, data.Length);
|
||||||
return GetResponse(url, stream, boundary, "multipart/form-data", cookies, headers, method);
|
return GetResponse(url, stream, boundary, "multipart/form-data", headers, cookies, method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpWebResponse GetResponse(string url, Stream dataStream, string boundary, string contentType,
|
private HttpWebResponse GetResponse(string url, Stream dataStream, string boundary, string contentType, NameValueCollection headers = null,
|
||||||
CookieCollection cookies = null, NameValueCollection headers = null, HttpMethod method = HttpMethod.POST)
|
CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
||||||
{
|
{
|
||||||
IsUploading = true;
|
IsUploading = true;
|
||||||
StopUploadRequested = false;
|
StopUploadRequested = false;
|
||||||
|
@ -285,9 +287,8 @@ private HttpWebResponse GetResponse(string url, Stream dataStream, string bounda
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UploadResult UploadData(Stream dataStream, string url, string fileName, string fileFormName = "file",
|
protected UploadResult UploadData(Stream dataStream, string url, string fileName, string fileFormName = "file", Dictionary<string, string> arguments = null,
|
||||||
Dictionary<string, string> arguments = null, CookieCollection cookies = null, NameValueCollection headers = null,
|
NameValueCollection headers = null, CookieCollection cookies = null, ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST)
|
||||||
ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST)
|
|
||||||
{
|
{
|
||||||
UploadResult result = new UploadResult();
|
UploadResult result = new UploadResult();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue