我收到以下错误:
Cannot process the message because the content type
'multipart/form-data;
boundary=0JxmnFLOmjvutAKrtR1bmPCqpG8M6WbwE-aAvh8' was not the expected
type 'text/xml; charset=utf-8'
安卓代码:
HttpPost httppost = new HttpPost("http://192.168.9.103/AndroidService/MediaUploadService.svc/uploadFile1");
File photo = new File(Environment.getExternalStorageDirectory(), "01.jpg");
MultipartEntity t = new MultipartEntity();
t.addPart("t", new FileBody(photo));
httppost.setEntity(t);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
WCF 代码:
public class MediaUploadService : IMediaUploadService
{
public void UploadFile(Stream fileContents)
{
byte[] buffer = new byte[10000];
int bytesRead, totalBytesRead = 0;
do
{
bytesRead = fileContents.Read(buffer, 0, buffer.Length);
totalBytesRead += bytesRead;
} while (bytesRead > 0);
File.WriteAllText(@"D:\\Vechile\log2.txt", totalBytesRead.ToString());
}
}
有人可以帮我完成这个过程吗?
我的问题:-
需要将图像文件从 Android 上传到服务器(通过 IIS -> .asp、.asmx、.svc 等)
有人可以建议我解决这个问题吗?