mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added $filename$ variable for custom uploader arguments
This commit is contained in:
parent
246cde1fe5
commit
c7f9f3c4f7
6 changed files with 9 additions and 8 deletions
|
@ -85,8 +85,8 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
throw new Exception("'Request type' must be 'POST' when using custom file uploader.");
|
throw new Exception("'Request type' must be 'POST' when using custom file uploader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(), customUploader.GetArguments(),
|
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(),
|
||||||
customUploader.GetHeaders(), responseType: customUploader.ResponseType);
|
customUploader.GetArguments(fileName), customUploader.GetHeaders(), responseType: customUploader.ResponseType);
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,7 +151,7 @@ public string GetFileFormName()
|
||||||
return FileFormName;
|
return FileFormName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> GetArguments(string input = null)
|
public Dictionary<string, string> GetArguments(string filename = "", string input = "")
|
||||||
{
|
{
|
||||||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ public Dictionary<string, string> GetArguments(string input = null)
|
||||||
string value = arg.Value;
|
string value = arg.Value;
|
||||||
|
|
||||||
value = NameParser.Parse(NameParserType.Text, value);
|
value = NameParser.Parse(NameParserType.Text, value);
|
||||||
|
value = value.Replace("$filename$", filename);
|
||||||
value = value.Replace("$input$", input);
|
value = value.Replace("$input$", input);
|
||||||
|
|
||||||
arguments.Add(arg.Key, value);
|
arguments.Add(arg.Key, value);
|
||||||
|
|
|
@ -82,8 +82,8 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
throw new Exception("'Request type' must be 'POST' when using custom image uploader.");
|
throw new Exception("'Request type' must be 'POST' when using custom image uploader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(), customUploader.GetArguments(),
|
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(),
|
||||||
customUploader.GetHeaders(), responseType: customUploader.ResponseType);
|
customUploader.GetArguments(fileName), customUploader.GetHeaders(), responseType: customUploader.ResponseType);
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ public override UploadResult ShareURL(string url)
|
||||||
|
|
||||||
UploadResult result = new UploadResult { URL = url, IsURLExpected = false };
|
UploadResult result = new UploadResult { URL = url, IsURLExpected = false };
|
||||||
|
|
||||||
Dictionary<string, string> args = customUploader.GetArguments(url);
|
Dictionary<string, string> args = customUploader.GetArguments("", url);
|
||||||
|
|
||||||
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
(customUploader.Arguments == null || !customUploader.Arguments.Any(x => x.Value.Contains("$input$"))))
|
(customUploader.Arguments == null || !customUploader.Arguments.Any(x => x.Value.Contains("$input$"))))
|
||||||
throw new Exception("Atleast one '$input$' required for argument value.");
|
throw new Exception("Atleast one '$input$' required for argument value.");
|
||||||
|
|
||||||
Dictionary<string, string> args = customUploader.GetArguments(text);
|
Dictionary<string, string> args = customUploader.GetArguments(fileName, text);
|
||||||
|
|
||||||
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,7 @@ public override UploadResult ShortenURL(string url)
|
||||||
|
|
||||||
UploadResult result = new UploadResult { URL = url };
|
UploadResult result = new UploadResult { URL = url };
|
||||||
|
|
||||||
Dictionary<string, string> args = customUploader.GetArguments(url);
|
Dictionary<string, string> args = customUploader.GetArguments("", url);
|
||||||
|
|
||||||
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
if (customUploader.RequestType == CustomUploaderRequestType.POST)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue