简体   繁体   中英

Best way to upload files from iOS app to Windows Server?

My iOS application allows a user to store files such as PDF's, Images, etc. We need to synchronize the app files to the cloud as we also offer the user a web portal to view the same data. I use WCF (Mtom encoding/streaming) in my Windows Forms app but this is not working in Xamarion.iOS (MonoTouch). There seems to be a problem with Mtom message encoding so I'm looking at an alternate and/or better way of getting files uploaded reliably such as streaming, showing progress, and using async await in C# 5 if possible.

What method do you recommend and if you have any sample code or links this would be great. Also, what is required in IIS 7.5 as I run Windows Server 2008 R2. Lastly, any firewall issues as I run a Watchguard appliance so if I need to open anything to allow this to work please advise. I assume though this would occur over HTTP or HTTPS.

I've done some research on web client, webDAV, etc, but not sure what is really the best approach for this scenario.

Thank you.

HttpClient (async) or WebClient will handle uploads just fine. You can create an ASP.NET upload handler or MVC action to read a HTTP posted file.

Some helpful links:

C# HttpClient 4.5 multipart/form-data upload

Getting the upload progress during file upload using Webclient.Uploadfile

http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx

Edit: See Larry OBrien's answer explaining the iOS 7 native MonoTouch.Foundation.NSUrlSession which allows background transfers.

iOS 7 introduces a new class, MonoTouch.Foundation.NSUrlSession , which is the preferred way to transfer larger files to and from the Web. NSUrlSession transfers can work when the application is in the background.

The programming model is explained in this article .

Here is a sample application that demonstrates the technique .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM