mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
Changed few functions parameter orders
This commit is contained in:
parent
65917c8ede
commit
b6f07906b5
|
@ -195,7 +195,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ public CopyAccountInfo GetAccountInfo()
|
|||
{
|
||||
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))
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ public UploadResult UploadFile(Stream stream, string path, string fileName)
|
|||
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.
|
||||
UploadResult result = UploadData(stream, query, fileName, "file", null, null, APIHeaders);
|
||||
UploadResult result = UploadData(stream, query, fileName, "file", headers: APIHeaders);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
|
|
|
@ -216,7 +216,7 @@ public DropboxContentInfo GetMetadata(string path, bool list)
|
|||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
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))
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ public string CreateShareableLink(string path, DropboxURLType urlType)
|
|||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
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))
|
||||
{
|
||||
|
@ -287,7 +287,7 @@ public DropboxContentInfo Copy(string from_path, string to_path)
|
|||
args.Add("from_path", from_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))
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ public DropboxContentInfo CreateFolder(string path)
|
|||
args.Add("root", Root);
|
||||
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))
|
||||
{
|
||||
|
@ -331,7 +331,7 @@ public DropboxContentInfo Delete(string path)
|
|||
args.Add("root", Root);
|
||||
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))
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ public DropboxContentInfo Move(string from_path, string to_path)
|
|||
args.Add("from_path", from_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))
|
||||
{
|
||||
|
|
|
@ -161,7 +161,7 @@ private void SetMetadata(string fileID, string title, string parentID = null)
|
|||
|
||||
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)
|
||||
|
@ -176,7 +176,7 @@ private void SetPermissions(string fileID, GoogleDrivePermissionRole role, Googl
|
|||
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)
|
||||
|
@ -198,7 +198,7 @@ public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true
|
|||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
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))
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
{
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(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)
|
||||
{
|
||||
|
|
|
@ -216,7 +216,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
NameValueCollection headers = new NameValueCollection();
|
||||
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"))
|
||||
{
|
||||
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");
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ public UploadResult PushFile(Stream stream, string fileName)
|
|||
args.Add("device_iden", Config.CurrentDevice.Key);
|
||||
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);
|
||||
|
||||
|
@ -74,7 +74,7 @@ private string Push(string pushType, string valueType, string value, string titl
|
|||
args.Add("title", title);
|
||||
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);
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
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))
|
||||
{
|
||||
|
|
|
@ -180,7 +180,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
NameValueCollection headers = GetAuthHeaders();
|
||||
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);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
{
|
||||
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
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
}
|
||||
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);
|
||||
|
|
|
@ -76,7 +76,7 @@ public bool GetAccessToken(string code)
|
|||
WebHeaderCollection headers = new WebHeaderCollection();
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
arguments.Add("lang", settings.TextFormat);
|
||||
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;
|
||||
|
|
|
@ -56,7 +56,7 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
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;
|
||||
|
|
|
@ -63,7 +63,7 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
arguments.Add("tabbing", "true");
|
||||
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;
|
||||
|
|
|
@ -54,11 +54,11 @@ public override UploadResult ShortenURL(string url)
|
|||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -114,8 +114,8 @@ public virtual void StopUpload()
|
|||
}
|
||||
}
|
||||
|
||||
protected string SendRequest(HttpMethod method, string url, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
|
||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
||||
protected string SendRequest(HttpMethod method, string url, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
|
||||
|
@ -141,20 +141,20 @@ public virtual void StopUpload()
|
|||
}
|
||||
}
|
||||
|
||||
protected string SendRequest(HttpMethod method, string url, string content, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
|
||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
||||
protected string SendRequest(HttpMethod method, string url, string content, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||
{
|
||||
byte[] data = Encoding.UTF8.GetBytes(content);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
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,
|
||||
NameValueCollection headers = null, CookieCollection cookies = null)
|
||||
protected string SendRequest(HttpMethod method, string url, Stream content, Dictionary<string, string> arguments = null, NameValueCollection headers = null,
|
||||
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
|
||||
{
|
||||
using (HttpWebResponse response = GetResponse(method, url, arguments, headers, cookies, content))
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ public virtual void StopUpload()
|
|||
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);
|
||||
|
||||
|
@ -227,19 +227,21 @@ protected string SendRequestJSON(string url, string json, CookieCollection cooki
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
byte[] data = MakeInputContent(boundary, arguments);
|
||||
|
@ -247,12 +249,12 @@ private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, stri
|
|||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
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,
|
||||
CookieCollection cookies = null, NameValueCollection headers = null, HttpMethod method = HttpMethod.POST)
|
||||
private HttpWebResponse GetResponse(string url, Stream dataStream, string boundary, string contentType, NameValueCollection headers = null,
|
||||
CookieCollection cookies = null, HttpMethod method = HttpMethod.POST)
|
||||
{
|
||||
IsUploading = true;
|
||||
StopUploadRequested = false;
|
||||
|
@ -285,9 +287,8 @@ private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, stri
|
|||
return null;
|
||||
}
|
||||
|
||||
protected UploadResult UploadData(Stream dataStream, string url, string fileName, string fileFormName = "file",
|
||||
Dictionary<string, string> arguments = null, CookieCollection cookies = null, NameValueCollection headers = null,
|
||||
ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST)
|
||||
protected UploadResult UploadData(Stream dataStream, string url, string fileName, string fileFormName = "file", Dictionary<string, string> arguments = null,
|
||||
NameValueCollection headers = null, CookieCollection cookies = null, ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST)
|
||||
{
|
||||
UploadResult result = new UploadResult();
|
||||
|
||||
|
|
Loading…
Reference in a new issue