Added $filename$ variable for custom uploader arguments

This commit is contained in:
Jaex 2018-02-02 02:36:55 +03:00
parent 246cde1fe5
commit c7f9f3c4f7
6 changed files with 9 additions and 8 deletions

View file

@ -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.");
}
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(), customUploader.GetArguments(),
customUploader.GetHeaders(), responseType: customUploader.ResponseType);
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(),
customUploader.GetArguments(fileName), customUploader.GetHeaders(), responseType: customUploader.ResponseType);
if (result.IsSuccess)
{

View file

@ -151,7 +151,7 @@ public string GetFileFormName()
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>();
@ -162,6 +162,7 @@ public string GetFileFormName()
string value = arg.Value;
value = NameParser.Parse(NameParserType.Text, value);
value = value.Replace("$filename$", filename);
value = value.Replace("$input$", input);
arguments.Add(arg.Key, value);

View file

@ -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.");
}
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(), customUploader.GetArguments(),
customUploader.GetHeaders(), responseType: customUploader.ResponseType);
UploadResult result = SendRequestFile(customUploader.GetRequestURL(), stream, fileName, customUploader.GetFileFormName(),
customUploader.GetArguments(fileName), customUploader.GetHeaders(), responseType: customUploader.ResponseType);
if (result.IsSuccess)
{

View file

@ -82,7 +82,7 @@ public override UploadResult ShareURL(string url)
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)
{

View file

@ -88,7 +88,7 @@ public override UploadResult UploadText(string text, string fileName)
(customUploader.Arguments == null || !customUploader.Arguments.Any(x => x.Value.Contains("$input$"))))
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)
{

View file

@ -83,7 +83,7 @@ public override UploadResult ShortenURL(string 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)
{