i am creating a wcf service in which i am receiving a base64 string and converting to image to store in my project.
this is my method:
public Boolean UploadProfile(int UserId, string base64String, string FileExtension)
{
try
{
string fileExtension;
byte[] bytes = Convert.FromBase64String(base64String);
if (FileExtension == "")
fileExtension = ".png";
else
fileExtension = FileExtension;
String timeStamp = GetTimestamp(DateTime.Now);
fileExtension = timeStamp + fileExtension;
string strFileName = "~/Images/" + fileExtension;
using (UserRegistrationBal UserregistrationBal = new UserRegistrationBal())
{
using (MemoryStream stream = new MemoryStream(bytes))
{
Image image = Image.FromStream(stream);
image.Save(HttpContext.Current.Server.MapPath(strFileName));
UserregistrationBal.UploadProfile(UserId, fileExtension);
}
return true;
}
}
catch (Exception ex)
{
ErrorLogManager.LogError(ex);
return false;
}
}
public static String GetTimestamp(DateTime value)
{
return value.ToString("yyyyMMddHHmmssffff");
}
My interface:
[ServiceContract]
public interface Services
{
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, Method = "POST")]
Boolean UploadProfile(int UserId, string base64String, string FileExtension);
}
now when i am calling this method from my rest client like this:
then my method is not calling from rest client.
i have kept debugger on my method but my nothing happens
when i am passing blank base64 parameter then my method is calling.
can anybody tell me whats the problem??
I think you have a issue with file size, please change maxBufferSize, maxBufferPoolSize and maxReceivedMessageSize to
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
from your binding then try, i think it should work. and try to add
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
in your binding. it will upload large file to REST Service.