mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Rename UploadHelpers to RequestHelpers
This commit is contained in:
parent
9a4853f5a3
commit
4a970ef3d1
28 changed files with 72 additions and 72 deletions
|
@ -137,7 +137,7 @@ internal string SendRequestURLEncoded(HttpMethod method, string url, Dictionary<
|
||||||
{
|
{
|
||||||
string query = URLHelpers.CreateQueryString(args);
|
string query = URLHelpers.CreateQueryString(args);
|
||||||
|
|
||||||
return SendRequest(method, url, query, UploadHelpers.ContentTypeURLEncoded, null, headers, cookies);
|
return SendRequest(method, url, query, RequestHelpers.ContentTypeURLEncoded, null, headers, cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool SendRequestDownload(HttpMethod method, string url, Stream downloadStream, Dictionary<string, string> args = null,
|
protected bool SendRequestDownload(HttpMethod method, string url, Stream downloadStream, Dictionary<string, string> args = null,
|
||||||
|
@ -162,9 +162,9 @@ protected bool SendRequestDownload(HttpMethod method, string url, Stream downloa
|
||||||
protected string SendRequestMultiPart(string url, Dictionary<string, string> args, NameValueCollection headers = null, CookieCollection cookies = null,
|
protected string SendRequestMultiPart(string url, Dictionary<string, string> args, NameValueCollection headers = null, CookieCollection cookies = null,
|
||||||
HttpMethod method = HttpMethod.POST)
|
HttpMethod method = HttpMethod.POST)
|
||||||
{
|
{
|
||||||
string boundary = UploadHelpers.CreateBoundary();
|
string boundary = RequestHelpers.CreateBoundary();
|
||||||
string contentType = UploadHelpers.ContentTypeMultipartFormData + "; boundary=" + boundary;
|
string contentType = RequestHelpers.ContentTypeMultipartFormData + "; boundary=" + boundary;
|
||||||
byte[] data = UploadHelpers.MakeInputContent(boundary, args);
|
byte[] data = RequestHelpers.MakeInputContent(boundary, args);
|
||||||
|
|
||||||
using (MemoryStream stream = new MemoryStream())
|
using (MemoryStream stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ protected string SendRequestMultiPart(string url, Dictionary<string, string> arg
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UploadResult SendRequestFile(string url, Stream data, string fileName, string fileFormName, Dictionary<string, string> args = null,
|
protected UploadResult SendRequestFile(string url, Stream data, string fileName, string fileFormName, Dictionary<string, string> args = null,
|
||||||
NameValueCollection headers = null, CookieCollection cookies = null, HttpMethod method = HttpMethod.POST, string contentType = UploadHelpers.ContentTypeMultipartFormData,
|
NameValueCollection headers = null, CookieCollection cookies = null, HttpMethod method = HttpMethod.POST, string contentType = RequestHelpers.ContentTypeMultipartFormData,
|
||||||
string relatedData = null)
|
string relatedData = null)
|
||||||
{
|
{
|
||||||
UploadResult result = new UploadResult();
|
UploadResult result = new UploadResult();
|
||||||
|
@ -188,22 +188,22 @@ protected UploadResult SendRequestFile(string url, Stream data, string fileName,
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string boundary = UploadHelpers.CreateBoundary();
|
string boundary = RequestHelpers.CreateBoundary();
|
||||||
contentType += "; boundary=" + boundary;
|
contentType += "; boundary=" + boundary;
|
||||||
|
|
||||||
byte[] bytesArguments = UploadHelpers.MakeInputContent(boundary, args, false);
|
byte[] bytesArguments = RequestHelpers.MakeInputContent(boundary, args, false);
|
||||||
byte[] bytesDataOpen;
|
byte[] bytesDataOpen;
|
||||||
|
|
||||||
if (relatedData != null)
|
if (relatedData != null)
|
||||||
{
|
{
|
||||||
bytesDataOpen = UploadHelpers.MakeRelatedFileInputContentOpen(boundary, "application/json; charset=UTF-8", relatedData, fileName);
|
bytesDataOpen = RequestHelpers.MakeRelatedFileInputContentOpen(boundary, "application/json; charset=UTF-8", relatedData, fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bytesDataOpen = UploadHelpers.MakeFileInputContentOpen(boundary, fileFormName, fileName);
|
bytesDataOpen = RequestHelpers.MakeFileInputContentOpen(boundary, fileFormName, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytesDataClose = UploadHelpers.MakeFileInputContentClose(boundary);
|
byte[] bytesDataClose = RequestHelpers.MakeFileInputContentClose(boundary);
|
||||||
|
|
||||||
long contentLength = bytesArguments.Length + bytesDataOpen.Length + data.Length + bytesDataClose.Length;
|
long contentLength = bytesArguments.Length + bytesDataOpen.Length + data.Length + bytesDataClose.Length;
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ protected UploadResult SendRequestFileRange(string url, Stream data, string file
|
||||||
}
|
}
|
||||||
contentLength = Math.Min(contentLength, data.Length - contentPosition);
|
contentLength = Math.Min(contentLength, data.Length - contentPosition);
|
||||||
|
|
||||||
string contentType = UploadHelpers.GetMimeType(fileName);
|
string contentType = RequestHelpers.GetMimeType(fileName);
|
||||||
|
|
||||||
if (headers == null)
|
if (headers == null)
|
||||||
{
|
{
|
||||||
|
@ -486,7 +486,7 @@ private HttpWebRequest CreateWebRequest(HttpMethod method, string url, NameValue
|
||||||
{
|
{
|
||||||
LastResponseInfo = null;
|
LastResponseInfo = null;
|
||||||
|
|
||||||
HttpWebRequest request = UploadHelpers.CreateWebRequest(method, url, headers, cookies, contentType, contentLength);
|
HttpWebRequest request = RequestHelpers.CreateWebRequest(method, url, headers, cookies, contentType, contentLength);
|
||||||
currentWebRequest = request;
|
currentWebRequest = request;
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,15 +179,15 @@ public string GetContentType()
|
||||||
switch (Body)
|
switch (Body)
|
||||||
{
|
{
|
||||||
case CustomUploaderBody.MultipartFormData:
|
case CustomUploaderBody.MultipartFormData:
|
||||||
return UploadHelpers.ContentTypeMultipartFormData;
|
return RequestHelpers.ContentTypeMultipartFormData;
|
||||||
case CustomUploaderBody.FormURLEncoded:
|
case CustomUploaderBody.FormURLEncoded:
|
||||||
return UploadHelpers.ContentTypeURLEncoded;
|
return RequestHelpers.ContentTypeURLEncoded;
|
||||||
case CustomUploaderBody.JSON:
|
case CustomUploaderBody.JSON:
|
||||||
return UploadHelpers.ContentTypeJSON;
|
return RequestHelpers.ContentTypeJSON;
|
||||||
case CustomUploaderBody.XML:
|
case CustomUploaderBody.XML:
|
||||||
return UploadHelpers.ContentTypeXML;
|
return RequestHelpers.ContentTypeXML;
|
||||||
case CustomUploaderBody.Binary:
|
case CustomUploaderBody.Binary:
|
||||||
return UploadHelpers.ContentTypeOctetStream;
|
return RequestHelpers.ContentTypeOctetStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -120,7 +120,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
string scope = URLHelpers.CombineURL(credentialDate, region, "s3", "aws4_request");
|
string scope = URLHelpers.CombineURL(credentialDate, region, "s3", "aws4_request");
|
||||||
string credential = URLHelpers.CombineURL(Settings.AccessKeyID, scope);
|
string credential = URLHelpers.CombineURL(Settings.AccessKeyID, scope);
|
||||||
string timeStamp = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture);
|
string timeStamp = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture);
|
||||||
string contentType = UploadHelpers.GetMimeType(fileName);
|
string contentType = RequestHelpers.GetMimeType(fileName);
|
||||||
string hashedPayload;
|
string hashedPayload;
|
||||||
|
|
||||||
if (Settings.SignedPayload)
|
if (Settings.SignedPayload)
|
||||||
|
|
|
@ -99,7 +99,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
|
|
||||||
OnEarlyURLCopyRequested(resultURL);
|
OnEarlyURLCopyRequested(resultURL);
|
||||||
|
|
||||||
string contentType = UploadHelpers.GetMimeType(fileName);
|
string contentType = RequestHelpers.GetMimeType(fileName);
|
||||||
|
|
||||||
NameValueCollection requestHeaders = new NameValueCollection();
|
NameValueCollection requestHeaders = new NameValueCollection();
|
||||||
requestHeaders["x-ms-date"] = date;
|
requestHeaders["x-ms-date"] = date;
|
||||||
|
|
|
@ -260,7 +260,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
/// <returns>Null if an error occurs, and <c>error</c> will contain an error message. Otherwise, a <see cref="B2Authorization"/>.</returns>
|
/// <returns>Null if an error occurs, and <c>error</c> will contain an error message. Otherwise, a <see cref="B2Authorization"/>.</returns>
|
||||||
private B2Authorization B2ApiAuthorize(string keyId, string key, out string error)
|
private B2Authorization B2ApiAuthorize(string keyId, string key, out string error)
|
||||||
{
|
{
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(keyId, key);
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(keyId, key);
|
||||||
|
|
||||||
using (HttpWebResponse res = GetResponse(HttpMethod.GET, B2AuthorizeAccountUrl, headers: headers, allowNon2xxResponses: true))
|
using (HttpWebResponse res = GetResponse(HttpMethod.GET, B2AuthorizeAccountUrl, headers: headers, allowNon2xxResponses: true))
|
||||||
{
|
{
|
||||||
|
@ -270,7 +270,7 @@ private B2Authorization B2ApiAuthorize(string keyId, string key, out string erro
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string body = UploadHelpers.ResponseToString(res);
|
string body = RequestHelpers.ResponseToString(res);
|
||||||
|
|
||||||
error = null;
|
error = null;
|
||||||
return JsonConvert.DeserializeObject<B2Authorization>(body);
|
return JsonConvert.DeserializeObject<B2Authorization>(body);
|
||||||
|
@ -308,7 +308,7 @@ private string B2ApiGetBucketId(B2Authorization auth, string bucketName, out str
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string body = UploadHelpers.ResponseToString(res);
|
string body = RequestHelpers.ResponseToString(res);
|
||||||
|
|
||||||
JObject json;
|
JObject json;
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ private B2UploadUrl B2ApiGetUploadUrl(B2Authorization auth, string bucketId, out
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string body = UploadHelpers.ResponseToString(res);
|
string body = RequestHelpers.ResponseToString(res);
|
||||||
|
|
||||||
error = null;
|
error = null;
|
||||||
return JsonConvert.DeserializeObject<B2UploadUrl>(body);
|
return JsonConvert.DeserializeObject<B2UploadUrl>(body);
|
||||||
|
@ -416,7 +416,7 @@ private B2UploadResult B2ApiUploadFile(B2UploadUrl b2UploadUrl, string destinati
|
||||||
["X-Bz-Info-b2-content-disposition"] = URLHelpers.URLEncode(contentDisposition.ToString()),
|
["X-Bz-Info-b2-content-disposition"] = URLHelpers.URLEncode(contentDisposition.ToString()),
|
||||||
};
|
};
|
||||||
|
|
||||||
string contentType = UploadHelpers.GetMimeType(destinationPath);
|
string contentType = RequestHelpers.GetMimeType(destinationPath);
|
||||||
|
|
||||||
using (HttpWebResponse res = GetResponse(HttpMethod.POST, b2UploadUrl.uploadUrl,
|
using (HttpWebResponse res = GetResponse(HttpMethod.POST, b2UploadUrl.uploadUrl,
|
||||||
contentType: contentType, headers: headers, data: file, allowNon2xxResponses: true))
|
contentType: contentType, headers: headers, data: file, allowNon2xxResponses: true))
|
||||||
|
@ -433,7 +433,7 @@ private B2UploadResult B2ApiUploadFile(B2UploadUrl b2UploadUrl, string destinati
|
||||||
return new B2UploadResult((int)res.StatusCode, ParseB2Error(res), null);
|
return new B2UploadResult((int)res.StatusCode, ParseB2Error(res), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
string body = UploadHelpers.ResponseToString(res);
|
string body = RequestHelpers.ResponseToString(res);
|
||||||
DebugHelper.WriteLine($"B2 uploader: B2ApiUploadFile() reports success! '{body}'");
|
DebugHelper.WriteLine($"B2 uploader: B2ApiUploadFile() reports success! '{body}'");
|
||||||
|
|
||||||
return new B2UploadResult((int)res.StatusCode, null, JsonConvert.DeserializeObject<B2Upload>(body));
|
return new B2UploadResult((int)res.StatusCode, null, JsonConvert.DeserializeObject<B2Upload>(body));
|
||||||
|
@ -491,11 +491,11 @@ private static bool IsAuthorizedForUpload(B2Authorization auth, string bucketId,
|
||||||
/// <exception cref="IOException">If the response body cannot be read.</exception>
|
/// <exception cref="IOException">If the response body cannot be read.</exception>
|
||||||
private static B2Error ParseB2Error(HttpWebResponse res)
|
private static B2Error ParseB2Error(HttpWebResponse res)
|
||||||
{
|
{
|
||||||
if (UploadHelpers.IsSuccessStatusCode(res.StatusCode)) return null;
|
if (RequestHelpers.IsSuccessStatusCode(res.StatusCode)) return null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string body = UploadHelpers.ResponseToString(res);
|
string body = RequestHelpers.ResponseToString(res);
|
||||||
DebugHelper.WriteLine($"B2 uploader: ParseB2Error() got: {body}");
|
DebugHelper.WriteLine($"B2 uploader: ParseB2Error() got: {body}");
|
||||||
B2Error err = JsonConvert.DeserializeObject<B2Error>(body);
|
B2Error err = JsonConvert.DeserializeObject<B2Error>(body);
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -87,7 +87,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
}
|
}
|
||||||
else if (uploader.Body == CustomUploaderBody.Binary)
|
else if (uploader.Body == CustomUploaderBody.Binary)
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, UploadHelpers.GetMimeType(fileName), null,
|
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, RequestHelpers.GetMimeType(fileName), null,
|
||||||
uploader.GetHeaders(input));
|
uploader.GetHeaders(input));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -176,7 +176,7 @@ public DropboxAccount GetCurrentAccount()
|
||||||
{
|
{
|
||||||
if (OAuth2Info.CheckOAuth(AuthInfo))
|
if (OAuth2Info.CheckOAuth(AuthInfo))
|
||||||
{
|
{
|
||||||
string response = SendRequest(HttpMethod.POST, URLGetCurrentAccount, "null", UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLGetCurrentAccount, "null", RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -199,7 +199,7 @@ public bool DownloadFile(string path, Stream downloadStream)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("arg", json);
|
args.Add("arg", json);
|
||||||
|
|
||||||
return SendRequestDownload(HttpMethod.POST, URLDownload, downloadStream, args, GetAuthHeaders(), null, UploadHelpers.ContentTypeJSON);
|
return SendRequestDownload(HttpMethod.POST, URLDownload, downloadStream, args, GetAuthHeaders(), null, RequestHelpers.ContentTypeJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -224,7 +224,7 @@ public UploadResult UploadFile(Stream stream, string path, string filename, bool
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("arg", json);
|
args.Add("arg", json);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLUpload, stream, UploadHelpers.ContentTypeOctetStream, args, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLUpload, stream, RequestHelpers.ContentTypeOctetStream, args, GetAuthHeaders());
|
||||||
|
|
||||||
UploadResult ur = new UploadResult(response);
|
UploadResult ur = new UploadResult(response);
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ public DropboxMetadata GetMetadata(string path)
|
||||||
include_has_explicit_shared_members = false
|
include_has_explicit_shared_members = false
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLGetMetadata, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLGetMetadata, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -295,7 +295,7 @@ public string CreateShareableLink(string path, bool directLink)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLCreateSharedLink, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLCreateSharedLink, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
DropboxLinkMetadata linkMetadata = null;
|
DropboxLinkMetadata linkMetadata = null;
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ public DropboxListSharedLinksResult ListSharedLinks(string path, bool directOnly
|
||||||
direct_only = directOnly
|
direct_only = directOnly
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLListSharedLinks, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLListSharedLinks, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -364,7 +364,7 @@ public DropboxMetadata Copy(string fromPath, string toPath)
|
||||||
to_path = VerifyPath(toPath)
|
to_path = VerifyPath(toPath)
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLCopy, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLCopy, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -386,7 +386,7 @@ public DropboxMetadata CreateFolder(string path)
|
||||||
path = VerifyPath(path)
|
path = VerifyPath(path)
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLCreateFolder, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLCreateFolder, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -408,7 +408,7 @@ public DropboxMetadata Delete(string path)
|
||||||
path = VerifyPath(path)
|
path = VerifyPath(path)
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLDelete, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLDelete, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -431,7 +431,7 @@ public DropboxMetadata Move(string fromPath, string toPath)
|
||||||
to_path = VerifyPath(toPath)
|
to_path = VerifyPath(toPath)
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLMove, json, UploadHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, URLMove, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,7 @@ public Ge_ttLogin Login(string email, string password)
|
||||||
string json = JsonConvert.SerializeObject(args);
|
string json = JsonConvert.SerializeObject(args);
|
||||||
|
|
||||||
string url = URLHelpers.CombineURL(APIURL, "users/login");
|
string url = URLHelpers.CombineURL(APIURL, "users/login");
|
||||||
string response = SendRequest(HttpMethod.POST, url, json, UploadHelpers.ContentTypeJSON);
|
string response = SendRequest(HttpMethod.POST, url, json, RequestHelpers.ContentTypeJSON);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<Ge_ttLogin>(response);
|
return JsonConvert.DeserializeObject<Ge_ttLogin>(response);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public Ge_ttFile CreateFile(string accessToken, string shareName, string fileNam
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(args2);
|
string json = JsonConvert.SerializeObject(args2);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URLHelpers.CombineURL(APIURL, "files", shareName, "create"), json, UploadHelpers.ContentTypeJSON, args);
|
string response = SendRequest(HttpMethod.POST, URLHelpers.CombineURL(APIURL, "files", shareName, "create"), json, RequestHelpers.ContentTypeJSON, args);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<Ge_ttFile>(response);
|
return JsonConvert.DeserializeObject<Ge_ttFile>(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ public bool GetAccessToken(string code)
|
||||||
code = code
|
code = code
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, UploadHelpers.ContentTypeJSON);
|
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, RequestHelpers.ContentTypeJSON);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ public bool RefreshAccessToken()
|
||||||
grant_type = "refresh"
|
grant_type = "refresh"
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, UploadHelpers.ContentTypeJSON);
|
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, RequestHelpers.ContentTypeJSON);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ private GfycatCreateResponse CreateGfycat(NameValueCollection headers)
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(args);
|
string json = JsonConvert.SerializeObject(args);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URL_API_CREATE_GFY, json, UploadHelpers.ContentTypeJSON, null, headers);
|
string response = SendRequest(HttpMethod.POST, URL_API_CREATE_GFY, json, RequestHelpers.ContentTypeJSON, null, headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
@ -305,7 +305,7 @@ private OAuth2Token GetOrCreateToken()
|
||||||
grant_type = "client_credentials",
|
grant_type = "client_credentials",
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, UploadHelpers.ContentTypeJSON);
|
string response = SendRequest(HttpMethod.POST, URL_API_TOKEN, request, RequestHelpers.ContentTypeJSON);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,7 +145,7 @@ private void SetPermissions(string fileID, GoogleDrivePermissionRole role, Googl
|
||||||
allowFileDiscovery = allowFileDiscovery.ToString()
|
allowFileDiscovery = allowFileDiscovery.ToString()
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, url, json, UploadHelpers.ContentTypeJSON, null, GoogleAuth.GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, url, json, RequestHelpers.ContentTypeJSON, null, GoogleAuth.GetAuthHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true)
|
public List<GoogleDriveFile> GetFolders(bool trashed = false, bool writer = true)
|
||||||
|
|
|
@ -72,7 +72,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 = UploadHelpers.CreateAuthenticationHeader(Email, Password);
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Email, Password);
|
||||||
result = SendRequestFile("https://api.hostr.co/file", stream, fileName, "file", headers: headers);
|
result = SendRequestFile("https://api.hostr.co/file", stream, fileName, "file", headers: headers);
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
|
|
|
@ -152,7 +152,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
|
|
||||||
public string PostRequestJson(Uri url, string jsonData)
|
public string PostRequestJson(Uri url, string jsonData)
|
||||||
{
|
{
|
||||||
return SendRequest(HttpMethod.POST, url.ToString(), jsonData, UploadHelpers.ContentTypeJSON);
|
return SendRequest(HttpMethod.POST, url.ToString(), jsonData, RequestHelpers.ContentTypeJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PostRequestRaw(Uri url, Stream dataStream)
|
public string PostRequestRaw(Uri url, Stream dataStream)
|
||||||
|
|
|
@ -212,7 +212,7 @@ private string CreateSession(string fileName)
|
||||||
string url = URLHelpers.BuildUri("https://graph.microsoft.com", $"/v1.0/{folderPath}:/{fileName}:/createUploadSession");
|
string url = URLHelpers.BuildUri("https://graph.microsoft.com", $"/v1.0/{folderPath}:/{fileName}:/createUploadSession");
|
||||||
|
|
||||||
AllowReportProgress = false;
|
AllowReportProgress = false;
|
||||||
string response = SendRequest(HttpMethod.POST, url, json, UploadHelpers.ContentTypeJSON, headers: GetAuthHeaders());
|
string response = SendRequest(HttpMethod.POST, url, json, RequestHelpers.ContentTypeJSON, headers: GetAuthHeaders());
|
||||||
AllowReportProgress = true;
|
AllowReportProgress = true;
|
||||||
|
|
||||||
OneDriveUploadSession session = JsonConvert.DeserializeObject<OneDriveUploadSession>(response);
|
OneDriveUploadSession session = JsonConvert.DeserializeObject<OneDriveUploadSession>(response);
|
||||||
|
@ -291,7 +291,7 @@ public string CreateShareableLink(string id, OneDriveLinkType linkType = OneDriv
|
||||||
type = linkTypeValue
|
type = linkTypeValue
|
||||||
});
|
});
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, $"https://graph.microsoft.com/v1.0/me/drive/items/{id}/createLink", json, UploadHelpers.ContentTypeJSON,
|
string response = SendRequest(HttpMethod.POST, $"https://graph.microsoft.com/v1.0/me/drive/items/{id}/createLink", json, RequestHelpers.ContentTypeJSON,
|
||||||
headers: GetAuthHeaders());
|
headers: GetAuthHeaders());
|
||||||
|
|
||||||
OneDrivePermission permissionInfo = JsonConvert.DeserializeObject<OneDrivePermission>(response);
|
OneDrivePermission permissionInfo = JsonConvert.DeserializeObject<OneDrivePermission>(response);
|
||||||
|
|
|
@ -109,10 +109,10 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
string url = URLHelpers.CombineURL(Host, "remote.php/webdav", encodedPath);
|
string url = URLHelpers.CombineURL(Host, "remote.php/webdav", encodedPath);
|
||||||
url = URLHelpers.FixPrefix(url);
|
url = URLHelpers.FixPrefix(url);
|
||||||
|
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Username, Password);
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Username, Password);
|
||||||
headers["OCS-APIREQUEST"] = "true";
|
headers["OCS-APIREQUEST"] = "true";
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.PUT, url, stream, UploadHelpers.GetMimeType(fileName), null, headers);
|
string response = SendRequest(HttpMethod.PUT, url, stream, RequestHelpers.GetMimeType(fileName), null, headers);
|
||||||
|
|
||||||
UploadResult result = new UploadResult(response);
|
UploadResult result = new UploadResult(response);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public string ShareFile(string path)
|
||||||
string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares?format=json");
|
string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares?format=json");
|
||||||
url = URLHelpers.FixPrefix(url);
|
url = URLHelpers.FixPrefix(url);
|
||||||
|
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Username, Password);
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Username, Password);
|
||||||
headers["OCS-APIREQUEST"] = "true";
|
headers["OCS-APIREQUEST"] = "true";
|
||||||
|
|
||||||
string response = SendRequestMultiPart(url, args, headers);
|
string response = SendRequestMultiPart(url, args, headers);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
metaDataReq.Files = new UploadMetadataRequestFile0();
|
metaDataReq.Files = new UploadMetadataRequestFile0();
|
||||||
metaDataReq.Files.File0 = new UploadMetadataRequestFile();
|
metaDataReq.Files.File0 = new UploadMetadataRequestFile();
|
||||||
metaDataReq.Files.File0.FileName = fileName;
|
metaDataReq.Files.File0.FileName = fileName;
|
||||||
metaDataReq.Files.File0.FileType = UploadHelpers.GetMimeType(fileName);
|
metaDataReq.Files.File0.FileType = RequestHelpers.GetMimeType(fileName);
|
||||||
metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length);
|
metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length);
|
||||||
metaDataReq.Removable = Settings.Removable;
|
metaDataReq.Removable = Settings.Removable;
|
||||||
metaDataReq.OneShot = Settings.OneShot;
|
metaDataReq.OneShot = Settings.OneShot;
|
||||||
|
|
|
@ -76,7 +76,7 @@ private const string
|
||||||
|
|
||||||
public UploadResult PushFile(Stream stream, string fileName)
|
public UploadResult PushFile(Stream stream, string fileName)
|
||||||
{
|
{
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
||||||
|
|
||||||
Dictionary<string, string> pushArgs, upArgs = new Dictionary<string, string>();
|
Dictionary<string, string> pushArgs, upArgs = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public UploadResult PushFile(Stream stream, string fileName)
|
||||||
|
|
||||||
private string Push(string pushType, string valueType, string value, string title)
|
private string Push(string pushType, string valueType, string value, string title)
|
||||||
{
|
{
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
||||||
|
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("device_iden", Config.CurrentDevice.Key);
|
args.Add("device_iden", Config.CurrentDevice.Key);
|
||||||
|
@ -174,7 +174,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
|
|
||||||
public List<PushbulletDevice> GetDeviceList()
|
public List<PushbulletDevice> GetDeviceList()
|
||||||
{
|
{
|
||||||
NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Config.UserAPIKey, "");
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.GET, apiGetDevicesURL, headers: headers);
|
string response = SendRequest(HttpMethod.GET, apiGetDevicesURL, headers: headers);
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password))
|
if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password))
|
||||||
{
|
{
|
||||||
headers = UploadHelpers.CreateAuthenticationHeader(Email, Password);
|
headers = RequestHelpers.CreateAuthenticationHeader(Email, Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
string url = URLHelpers.CombineURL(Host, "upload");
|
string url = URLHelpers.CombineURL(Host, "upload");
|
||||||
|
|
|
@ -35,7 +35,7 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
namespace ShareX.UploadersLib
|
namespace ShareX.UploadersLib
|
||||||
{
|
{
|
||||||
internal static class UploadHelpers
|
internal static class RequestHelpers
|
||||||
{
|
{
|
||||||
public const string ContentTypeMultipartFormData = "multipart/form-data";
|
public const string ContentTypeMultipartFormData = "multipart/form-data";
|
||||||
public const string ContentTypeJSON = "application/json";
|
public const string ContentTypeJSON = "application/json";
|
|
@ -32,7 +32,7 @@ public class ResponseInfo
|
||||||
{
|
{
|
||||||
public HttpStatusCode StatusCode { get; set; }
|
public HttpStatusCode StatusCode { get; set; }
|
||||||
public string StatusDescription { get; set; }
|
public string StatusDescription { get; set; }
|
||||||
public bool IsSuccess => UploadHelpers.IsSuccessStatusCode(StatusCode);
|
public bool IsSuccess => RequestHelpers.IsSuccessStatusCode(StatusCode);
|
||||||
public string ResponseURL { get; set; }
|
public string ResponseURL { get; set; }
|
||||||
public WebHeaderCollection Headers { get; set; }
|
public WebHeaderCollection Headers { get; set; }
|
||||||
public string ResponseText { get; set; }
|
public string ResponseText { get; set; }
|
||||||
|
|
|
@ -84,7 +84,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
}
|
}
|
||||||
else if (uploader.Body == CustomUploaderBody.Binary)
|
else if (uploader.Body == CustomUploaderBody.Binary)
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, UploadHelpers.GetMimeType(fileName),
|
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, RequestHelpers.GetMimeType(fileName),
|
||||||
null, uploader.GetHeaders(input));
|
null, uploader.GetHeaders(input));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -108,7 +108,7 @@ public GooglePhotosAlbum CreateAlbum(string albumName)
|
||||||
};
|
};
|
||||||
|
|
||||||
string serializedNewItemAlbum = JsonConvert.SerializeObject(newItemAlbum);
|
string serializedNewItemAlbum = JsonConvert.SerializeObject(newItemAlbum);
|
||||||
string serializedNewItemAlbumResponse = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/albums", serializedNewItemAlbum, UploadHelpers.ContentTypeJSON, newItemAlbumArgs, GoogleAuth.GetAuthHeaders());
|
string serializedNewItemAlbumResponse = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/albums", serializedNewItemAlbum, RequestHelpers.ContentTypeJSON, newItemAlbumArgs, GoogleAuth.GetAuthHeaders());
|
||||||
GooglePhotosAlbum newItemAlbumResponse = JsonConvert.DeserializeObject<GooglePhotosAlbum>(serializedNewItemAlbumResponse);
|
GooglePhotosAlbum newItemAlbumResponse = JsonConvert.DeserializeObject<GooglePhotosAlbum>(serializedNewItemAlbumResponse);
|
||||||
|
|
||||||
return newItemAlbumResponse;
|
return newItemAlbumResponse;
|
||||||
|
@ -180,7 +180,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
GooglePhotosAlbumOptions albumOptions = new GooglePhotosAlbumOptions();
|
GooglePhotosAlbumOptions albumOptions = new GooglePhotosAlbumOptions();
|
||||||
|
|
||||||
string serializedAlbumOptions = JsonConvert.SerializeObject(albumOptions);
|
string serializedAlbumOptions = JsonConvert.SerializeObject(albumOptions);
|
||||||
string serializedAlbumOptionsResponse = SendRequest(HttpMethod.POST, $"https://photoslibrary.googleapis.com/v1/albums/{AlbumID}:share", serializedAlbumOptions, UploadHelpers.ContentTypeJSON, albumOptionsResponseArgs, GoogleAuth.GetAuthHeaders());
|
string serializedAlbumOptionsResponse = SendRequest(HttpMethod.POST, $"https://photoslibrary.googleapis.com/v1/albums/{AlbumID}:share", serializedAlbumOptions, RequestHelpers.ContentTypeJSON, albumOptionsResponseArgs, GoogleAuth.GetAuthHeaders());
|
||||||
GooglePhotosAlbumOptionsResponse albumOptionsResponse = JsonConvert.DeserializeObject<GooglePhotosAlbumOptionsResponse>(serializedAlbumOptionsResponse);
|
GooglePhotosAlbumOptionsResponse albumOptionsResponse = JsonConvert.DeserializeObject<GooglePhotosAlbumOptionsResponse>(serializedAlbumOptionsResponse);
|
||||||
|
|
||||||
result.URL = albumOptionsResponse.shareInfo.shareableUrl;
|
result.URL = albumOptionsResponse.shareInfo.shareableUrl;
|
||||||
|
@ -193,7 +193,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
{ "Authorization", GoogleAuth.GetAuthHeaders()["Authorization"] }
|
{ "Authorization", GoogleAuth.GetAuthHeaders()["Authorization"] }
|
||||||
};
|
};
|
||||||
|
|
||||||
string uploadToken = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/uploads", stream, UploadHelpers.ContentTypeOctetStream, null, uploadTokenHeaders);
|
string uploadToken = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/uploads", stream, RequestHelpers.ContentTypeOctetStream, null, uploadTokenHeaders);
|
||||||
|
|
||||||
GooglePhotosNewMediaItemRequest newMediaItemRequest = new GooglePhotosNewMediaItemRequest
|
GooglePhotosNewMediaItemRequest newMediaItemRequest = new GooglePhotosNewMediaItemRequest
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
|
|
||||||
string serializedNewMediaItemRequest = JsonConvert.SerializeObject(newMediaItemRequest);
|
string serializedNewMediaItemRequest = JsonConvert.SerializeObject(newMediaItemRequest);
|
||||||
|
|
||||||
result.Response = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate", serializedNewMediaItemRequest, UploadHelpers.ContentTypeJSON, newMediaItemRequestArgs, GoogleAuth.GetAuthHeaders());
|
result.Response = SendRequest(HttpMethod.POST, "https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate", serializedNewMediaItemRequest, RequestHelpers.ContentTypeJSON, newMediaItemRequestArgs, GoogleAuth.GetAuthHeaders());
|
||||||
|
|
||||||
GooglePhotosNewMediaItemResults newMediaItemResult = JsonConvert.DeserializeObject<GooglePhotosNewMediaItemResults>(result.Response);
|
GooglePhotosNewMediaItemResults newMediaItemResult = JsonConvert.DeserializeObject<GooglePhotosNewMediaItemResults>(result.Response);
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
<Compile Include="Helpers\MimeTypes.cs" />
|
<Compile Include="Helpers\MimeTypes.cs" />
|
||||||
<Compile Include="Helpers\OCROptions.cs" />
|
<Compile Include="Helpers\OCROptions.cs" />
|
||||||
<Compile Include="Helpers\ResponseInfo.cs" />
|
<Compile Include="Helpers\ResponseInfo.cs" />
|
||||||
<Compile Include="Helpers\UploadHelpers.cs" />
|
<Compile Include="Helpers\RequestHelpers.cs" />
|
||||||
<Compile Include="OAuth\GoogleOAuth2.cs" />
|
<Compile Include="OAuth\GoogleOAuth2.cs" />
|
||||||
<Compile Include="OAuth\IOAuthBase.cs" />
|
<Compile Include="OAuth\IOAuthBase.cs" />
|
||||||
<Compile Include="OAuth\OAuth2ProofKey.cs" />
|
<Compile Include="OAuth\OAuth2ProofKey.cs" />
|
||||||
|
|
|
@ -113,7 +113,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(text);
|
byte[] bytes = Encoding.UTF8.GetBytes(text);
|
||||||
using (MemoryStream stream = new MemoryStream(bytes))
|
using (MemoryStream stream = new MemoryStream(bytes))
|
||||||
{
|
{
|
||||||
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, UploadHelpers.GetMimeType(fileName),
|
result.Response = SendRequest(uploader.RequestMethod, uploader.GetRequestURL(input), stream, RequestHelpers.GetMimeType(fileName),
|
||||||
null, uploader.GetHeaders(input));
|
null, uploader.GetHeaders(input));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public bool GetAccessToken(string code)
|
||||||
args.Add("code", code);
|
args.Add("code", code);
|
||||||
|
|
||||||
WebHeaderCollection headers = new WebHeaderCollection();
|
WebHeaderCollection headers = new WebHeaderCollection();
|
||||||
headers.Add("Accept", UploadHelpers.ContentTypeJSON);
|
headers.Add("Accept", RequestHelpers.ContentTypeJSON);
|
||||||
|
|
||||||
string response = SendRequestMultiPart("https://github.com/login/oauth/access_token", args, headers);
|
string response = SendRequestMultiPart("https://github.com/login/oauth/access_token", args, headers);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("access_token", AuthInfo.Token.access_token);
|
args.Add("access_token", AuthInfo.Token.access_token);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, url, json, UploadHelpers.ContentTypeJSON, args);
|
string response = SendRequest(HttpMethod.POST, url, json, RequestHelpers.ContentTypeJSON, args);
|
||||||
|
|
||||||
GistResponse gistResponse = JsonConvert.DeserializeObject<GistResponse>(response);
|
GistResponse gistResponse = JsonConvert.DeserializeObject<GistResponse>(response);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(API_USERNAME) && !string.IsNullOrEmpty(API_KEY))
|
if (!string.IsNullOrEmpty(API_USERNAME) && !string.IsNullOrEmpty(API_KEY))
|
||||||
{
|
{
|
||||||
headers = UploadHelpers.CreateAuthenticationHeader(API_USERNAME, API_KEY);
|
headers = RequestHelpers.CreateAuthenticationHeader(API_USERNAME, API_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Response = SendRequestMultiPart(API_ENDPOINT, args, headers);
|
result.Response = SendRequestMultiPart(API_ENDPOINT, args, headers);
|
||||||
|
|
|
@ -104,7 +104,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
NameValueCollection headers = new NameValueCollection();
|
NameValueCollection headers = new NameValueCollection();
|
||||||
headers.Add("X-Auth-Token", APIKey);
|
headers.Add("X-Auth-Token", APIKey);
|
||||||
|
|
||||||
ur.Response = SendRequest(HttpMethod.POST, "https://api.paste.ee/v1/pastes", json, UploadHelpers.ContentTypeJSON, null, headers);
|
ur.Response = SendRequest(HttpMethod.POST, "https://api.paste.ee/v1/pastes", json, RequestHelpers.ContentTypeJSON, null, headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ur.Response))
|
if (!string.IsNullOrEmpty(ur.Response))
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,7 +115,7 @@ public override UploadResult ShortenURL(string url)
|
||||||
};
|
};
|
||||||
|
|
||||||
string serializedRequestOptions = JsonConvert.SerializeObject(requestOptions);
|
string serializedRequestOptions = JsonConvert.SerializeObject(requestOptions);
|
||||||
result.Response = SendRequest(HttpMethod.POST, "https://firebasedynamiclinks.googleapis.com/v1/shortLinks", serializedRequestOptions, UploadHelpers.ContentTypeJSON, args);
|
result.Response = SendRequest(HttpMethod.POST, "https://firebasedynamiclinks.googleapis.com/v1/shortLinks", serializedRequestOptions, RequestHelpers.ContentTypeJSON, args);
|
||||||
|
|
||||||
FirebaseResponse firebaseResponse = JsonConvert.DeserializeObject<FirebaseResponse>(result.Response);
|
FirebaseResponse firebaseResponse = JsonConvert.DeserializeObject<FirebaseResponse>(result.Response);
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public string Submit(string url)
|
||||||
NameValueCollection headers = new NameValueCollection();
|
NameValueCollection headers = new NameValueCollection();
|
||||||
headers.Add("X-API-Key", Settings.APIKey);
|
headers.Add("X-API-Key", Settings.APIKey);
|
||||||
|
|
||||||
string response = SendRequest(HttpMethod.POST, requestURL, json, UploadHelpers.ContentTypeJSON, headers: headers);
|
string response = SendRequest(HttpMethod.POST, requestURL, json, RequestHelpers.ContentTypeJSON, headers: headers);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(response))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue