我正在为iphone应用创建WCF。我想知道如何使用json wcf将照片上传到sql任何想法?这是如何将它连接到sql的过程?
public class TestService : ITestService
{
[WebInvoke(Method = "POST", UriTemplate = "UploadFile?fileName={fileName}")]
public string UploadFile(string fileName, Stream fileContents)
{
//save file
string absFileName = "";
try
{
absFileName = string.Format("{0}\\FileUpload\\{1}"
, AppDomain.CurrentDomain.BaseDirectory
, Guid.NewGuid().ToString().Substring(0,6) + ".jpg");
// string fld = @"h:\root\home\amrmk185-001\www\publish\WCFService\FileUpload\" + fileName;
//System.IO.File.Create(absFileName);
using (FileStream fs = new FileStream(absFileName, FileMode.Create))
{
fileContents.CopyTo(fs);
fileContents.Close();
}
return "Upload OK";
}
catch(Exception ex)
{
return "FAIL ==> " + ex.Message + " " + absFileName;
}
}