Reputation: 311
Well Ive looked for hours and hours after an answer but havent really found anything that I could use.
All solutions Ive seen concentrate on the android part and never on the service part. I need both. :)
Upvotes: 9
Views: 2168
Reputation: 11
Ion.with(getActivity())
.load(URL)
.setMultipartFile("upload", "image/jpeg", fileToUpload)
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception arg0, String result) {
hideProgressDialog();
if(result!=null){
CoreFragment.this.resultCallBack.returnResult(result.toString());
} else {
showErrorToast("Error");
}
}
});
and wcf is
public string upload(Stream stream)
{
MultipartParser parser = new MultipartParser(stream);
if (parser.Success)
{
try
{
string strServerpath = @"C:\IISWebsite\DOTNET\BGGTS\Files\AttendanceProof\" + parser.Filename;
File.WriteAllBytes(strServerpath, parser.FileContents);
}
catch (Exception ex)
{
return "Failed";
}
}
return "Success";
}
Upvotes: 0
Reputation: 3830
This blog post http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/ describes how you can upload files with HTTP POST - which you must use from Android if you want to upload files to a WCF service wired up with webHttpBinding.
Extra metadata can be sent as HTTP headers.
--larsw
Upvotes: 3