A service is being developed to upload images from an android application.
1-HttpAPI is used, the first attempt was made by passing the image in base64
[ServiceMethod]
[ApiMethod(HttpApiMethod = ApiRequestMethod.Post, HttpApiPath = “protected/UploadFile/{Client}/{File}/{Name}”, HttpApiTags = new { “service” })]public int UploadFile(string Client, string File,string Name) { try { int result = BLFile.Instance().UploadFile(Client, File, Name, Program.l_AppConf); //return result; return 1; } catch (ErrorException ex1) { throw new ApiMethodException(HttpStatusCode.NotFound, ex1.ReturnMessage); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new ApiMethodException(HttpStatusCode.NotFound); } }
In the client when sending the image in base64 this error is received
The connection is terminated: A connection that was expected to remain active was closed by the server.
2-Second attempt using a byte array
[ServiceMethod]
[ApiMethod(HttpApiMethod = ApiRequestMethod.Post, HttpApiPath = "protected/UploadFileB/{Client}/{photoData}/{Name}", HttpApiTags = new[] { "service" })]
public int UploadFileB(string Client, Binary photoData, string Name)
{
try
{
//Guardar imagen
return 1;
}
catch (ErrorException ex1)
{
throw new ApiMethodException(HttpStatusCode.NotFound, ex1.ReturnMessage);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw new ApiMethodException(HttpStatusCode.NotFound);
}
}
Error: Invalid URI: the URI string is too long
please help.