2
안드로이드에서 원격 웹 서비스로 이미지 파일 업로드에 문제가 있습니다. asp net C#.이미지 업로드 빈 파일
안드로이드에서 원격 서버로 보낸 이미지 파일은 0 킬로바이트입니다. 업로드 된 이미지 파일 이름이 올바른 원격 서버의 폴더에 올바른 디버그 안드로이드 및 디버그 ASP NET에서 있지만이 이미지가 비어 있지 않습니다.
감사합니다. 사전에
감사
자바 클래스안드로이드 코드 : ASP를 그물 C#에서
이File mFile = new File("/storage/emulated/0/image_file.jpg");
if(mFile.exists()){
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Bitmap bmp = BitmapFactory.decodeFile(mFile.getAbsolutePath());
bmp.recycle();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Request.addProperty("byteArray", byteArray);
}
WebService에
[WebMethod]
public string sendUpload(Byte[] byteArray, string fileName)
{
string Path;
Path = "D:\\Inetpub\\wwwroot\\myAppAndroid\\uploads\\" + fileName;
FileStream objfilestream = new FileStream(Path, FileMode.Create,
FileAccess.ReadWrite);
objfilestream.Close();
return byteArray + "; " + fileName.ToString();
}
먼저 편집 질문, 내가 가진이 라인에서 오류
file.Write(byteArray, 0, byteArray.Length);
[WebMethod]
public string sendUpload(Byte[] byteArray, string fileName)
{
string strdocPath;
strdocPath = "D:\\Inetpub\\wwwroot\\myAppAndroid\\uploads\\" + fileName;
System.IO.FileStream file = System.IO.File.Create(HttpContext.Current.Server.MapPath(".\\myAppAndroid\\uploads\\" + fileName));
file.Write(byteArray, 0, byteArray.Length);
file.Close();
return byteArray + "; " + fileName.ToString();
}
VS는 사용하지 않은 경우 VS가 사용하지 않는 변수를 표시하고 경고를하기 때문에 직접 오류를 발견했을 것입니다. 하지만 그는 그것을 파일 시스템에 쓰지 않고 그것을 사용하고 있습니다. (@ChevyMarkSunderland : 방금 보낸 메시지를 사용자에게 보냈을 때 왜 당신에게 이미지를 보냈 을까요? 복사 및 그것을 다시 필요가 없습니다 ...;)) – Alexander
고맙습니다하지만 문제가 안드로이드 또는 webservice에서 발생하는 경우 이해가 안 돼요 ... –
@ ChevyMarkSunderland 귀하의 webservice C# 코드는 파일의 내용을 쓰고 있지 않습니다 파일 시스템에. 파일 시스템에 내용을 쓰지 않으면 파일은 항상 비어있게됩니다. 당신은 파일이 비어 있지 않은 파일을 가지고 뭔가를 작성해야합니다 ... – Paolo