Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Visual Studio download a document from a document libary and upload it to a jaxrs webservice in java

$
0
0

I have created a custom ribbon action and a application page in visual studio. The user presses my ribbon in sharepoint and it calls the application page that in turn downloads that file. here is the code:

namespace Save_to_PLM.Layouts.Save_to_PLM
    {
        public partial class ApplicationPage : LayoutsPageBase
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (Request.QueryString["file"] != null)
                    DownloadDocument(Request.QueryString["file"].ToString());
            }

            private void DownloadDocument(string fileName)
            {

                SPSecurity.RunWithElevatedPrivileges(delegate()
                {

                    using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.Url))
                    {
                        using (SPWeb mi_web = oSiteCollection.OpenWeb())
                        {

                            string path = System.Web.HttpContext.Current.Server.MapPath(fileName);
                            string name = System.IO.Path.GetFileName(path);
                            Console.WriteLine(name);
                            Microsoft.SharePoint.SPFile spFile = mi_web.GetFile(fileName);

                            Response.ClearHeaders();
                            Response.ClearContent();

                            Response.ContentType = "application/force-download";
                            Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                            Response.BinaryWrite(spFile.OpenBinary());
                            Response.End();
                        }
                    }
                });
            }
        }
    }

But i want to http post that file to my jaxrs webservice in java. How do  i do that programmatically? I am very new .net i usually code in java.



Viewing all articles
Browse latest Browse all 7589

Trending Articles