This commit is contained in:
@@ -5731,10 +5731,17 @@ namespace AyaNova.PlugIn.V8
|
|||||||
//Upload
|
//Upload
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if(DEBUG)
|
||||||
|
progress.Append("Sending file " + fi.Name);
|
||||||
|
#endif
|
||||||
await util.PostFormDataAsync("attachment", formDataContent);
|
await util.PostFormDataAsync("attachment", formDataContent);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
#if(DEBUG)
|
||||||
|
progress.Append("ERROR Sending file " + fi.Name);
|
||||||
|
#endif
|
||||||
if (ex.Message.Contains("413"))
|
if (ex.Message.Contains("413"))
|
||||||
{
|
{
|
||||||
if (SmallestFileUploadRejectedAsTooBig > fi.Length)
|
if (SmallestFileUploadRejectedAsTooBig > fi.Length)
|
||||||
@@ -5750,7 +5757,9 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//No need to map it or save response as long as it works that's all that matters
|
//No need to map it or save response as long as it works that's all that matters
|
||||||
|
#if(DEBUG)
|
||||||
|
progress.Append("File attached successfully " + fi.Name);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
public const string API_BASE_ROUTE = "api/v8/";
|
public const string API_BASE_ROUTE = "api/v8/";
|
||||||
private const int MAX_TRIES = 3;//max times to retry an api call before giving up
|
private const int MAX_TRIES = 3;//max times to retry an api call before giving up
|
||||||
private const int API_RETRY_DELAY = 3000;//pause in ms before retrying api call
|
private const int API_RETRY_DELAY = 3000;//pause in ms before retrying api call
|
||||||
private const int HTTPCLIENT_TIMEOUT_SECONDS = 300;//default for all ops, normally 100seconds but would kill large file uploads
|
private const int HTTPCLIENT_TIMEOUT_SECONDS = 1200;//default for all ops, normally 100seconds but would kill large file uploads
|
||||||
public static HttpClient client = null;
|
public static HttpClient client = null;
|
||||||
//url once known to be good
|
//url once known to be good
|
||||||
internal static string ApiBaseUrl { get; set; }
|
internal static string ApiBaseUrl { get; set; }
|
||||||
@@ -355,33 +355,38 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//public async static Task<ApiResponse> PostFormDataAsync(string route, MultipartFormDataContent formContent)
|
||||||
|
//{
|
||||||
|
// Exception FirstException = null;
|
||||||
|
|
||||||
|
// for (int x = 0; x < MAX_TRIES; x++)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// return await TryPostFormDataAsync(route, formContent);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// if (ex.Message.Contains("413")) throw;//too large, no point in retrying at all let upstream caller handle it immediately
|
||||||
|
|
||||||
|
// if (FirstException == null)
|
||||||
|
// FirstException = ex;
|
||||||
|
// }
|
||||||
|
// await Task.Delay(API_RETRY_DELAY);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //no luck re-throw the exception
|
||||||
|
// throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//NO RETRY TEST VERSION OF ABOVE
|
||||||
|
//UNCOMMENT ABOVE AND COMMENT THIS TO GO BACK
|
||||||
public async static Task<ApiResponse> PostFormDataAsync(string route, MultipartFormDataContent formContent)
|
public async static Task<ApiResponse> PostFormDataAsync(string route, MultipartFormDataContent formContent)
|
||||||
{
|
{
|
||||||
Exception FirstException = null;
|
return await TryPostFormDataAsync(route, formContent);
|
||||||
|
|
||||||
for (int x = 0; x < MAX_TRIES; x++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return await TryPostFormDataAsync(route, formContent);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (ex.Message.Contains("413")) throw;//too large, no point in retrying at all let upstream caller handle it immediately
|
|
||||||
|
|
||||||
if (FirstException == null)
|
|
||||||
FirstException = ex;
|
|
||||||
}
|
|
||||||
await Task.Delay(API_RETRY_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
//no luck re-throw the exception
|
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async static Task<ApiResponse> TryPostFormDataAsync(string route, MultipartFormDataContent formContent)
|
private async static Task<ApiResponse> TryPostFormDataAsync(string route, MultipartFormDataContent formContent)
|
||||||
{
|
{
|
||||||
var requestMessage = new HttpRequestMessage(HttpMethod.Post, ApiBaseUrl + route);
|
var requestMessage = new HttpRequestMessage(HttpMethod.Post, ApiBaseUrl + route);
|
||||||
|
|||||||
Reference in New Issue
Block a user