0

So we have a requirement to upload file to sharepoint server using iOS client . We are able to upload file size till 40kb but the problem is the file data we are passing is in Base64 encoding,and it fails for file size more than 40kb because we cannot pass large data in soap message,so we tried different approaches possible and mentioned on web . These are the ways we tried out

and we are left with only sending data using MTOM .

After lots of experiments and search I think MTOM is a way to upload data using soap . We are using CopyIntoItems sharepoint service for upload .

Soap request looks like

   <"xmlns:soap12=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                                     "<soap12:Body>\n"
                                     "<CopyIntoItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
                                     "<SourceUrl>%@</SourceUrl>\n"
                                     "<DestinationUrls>\n"
                                     "<string>%@</string>\n"
                                     "</DestinationUrls>\n"
                                     "<Fields>\n"
                                     "%@"
                                     "</Fields>\n"
                                     "<Stream>MY_FILE_DATA</Stream>\n"
                                     "</CopyIntoItems>\n"
                                     "</soap12:Body>\n"
                                     "</soap12:Envelope>\n"

Now the problem is how do we format this soap request in the way MTOM accepts,because CopyIntoItems may not work in some other format.

Few samples of MTOM which i looked into

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/cwbs_soapmtom.html

http://cxf.apache.org/docs/mtom.html

Any help would be much appreciated..Thanks..!!

Abhinandan Sahgal
  • 1,076
  • 1
  • 13
  • 27

1 Answers1

0

What about using HTTP post and developing an Http handler to store posted data?

It is quite easy to setup an http handler in Sharepoint (MSDN) and in the Process request method you can use query string to get the information you need. Say you create an Upload.ashx handler.

public void ProcessRequest(HttpContext context)
{
  var targetList = context.Request["targetList"];
  var targetFileName = context.Request["targetFn"];
  // Get the stream to content
  var stream = context.Request.GetBufferedInputStream();
  // Save the file somewhere
}

From the client you do an HTTP post to http://server/_layouts/15/Upload.ashx?targetList=myFiles&...

Stefano Altieri
  • 4,550
  • 1
  • 24
  • 41
  • Thanks Stefano. As we are developing this application in iOS(iPhone/iPad) ,so couldnot really use the classes or APIS of MSDN or C# . If you can explain the steps i can try out converting those in iOS. – Abhinandan Sahgal Dec 03 '13 at 15:52
  • The code I wrote is for the server side (SharePoint). On the client side it as simple Http Post. If you fave no access to the server side then you cannot apply this solution. – Stefano Altieri Dec 03 '13 at 16:53
  • We can make this change on the server,but the problem is with simple HTTP post how we can use Sharepoint query CopyIntoItems ? – Abhinandan Sahgal Dec 03 '13 at 17:11
  • Sorry I cannot test the code (I have no SharePoint dev env at the moment). You can refer to http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems%28v=office.12%29.aspx . There is a full code sample. Hope this helps. – Stefano Altieri Dec 04 '13 at 08:15