2

Most of the solutions I've come across for Sharepoint doc library uploads use the HTTP "PUT" method, but I'm having trouble finding a way to do this in Silverlight because it has restrictions on the HTTP Methods. I visited this http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx to see how to allow PUT in my code, but I can't find how that helps you use an HTTP "PUT".

I am using client web-services, so that limits some of the Sharepoint functions available.

That leaves me with these questions:

  1. Can I do an http PUT in Silverlight?
  2. If I can't or there is another better way to upload a file, what is it?

Thanks

2 Answers 2

1

Figured it out!! works like a charm

    public void UploadFile(String fileName, byte[] file)
    {
        // format the destination URL

        string[] destinationUrls = {"http://qa.sp.dca/sites/silverlight/Answers/"+fileName}; 

        // fill out the metadata
        // remark: don't set the Name field, because this is the name of the document

        SharepointCopy.FieldInformation titleInformation = new SharepointCopy.FieldInformation
            {DisplayName =fileName, 
             InternalName =fileName, 
             Type = SharepointCopy.FieldType.Text, 
             Value =fileName};

        // to specify the content type

        SharepointCopy.FieldInformation ctInformation = new SharepointCopy.FieldInformation
            {DisplayName ="XML Answer Doc", 
             InternalName ="ContentType", 
             Type = SharepointCopy.
             FieldType.Text, 
             Value ="xml"};

        SharepointCopy.FieldInformation[] metadata = { titleInformation }; 

        // initialize the web service

        SharepointCopy.CopySoapClient copyws = new SharepointCopy.CopySoapClient(); 

        // execute the CopyIntoItems method
        copyws.CopyIntoItemsCompleted += copyws_CopyIntoItemsCompleted;
        copyws.CopyIntoItemsAsync("http://null", destinationUrls, metadata, file);
    }

Many Thanks to Karine Bosch for the solution here: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/f135aaa2-3345-483f-ade4-e4fd597d50d4

Sign up to request clarification or add additional context in comments.

Comments

0

What type of SharePoint deployment and what version of silverlight? If say it is an intranet deployment you could use UNC paths to access your document library in sharepoint and the savefiledialog/openfiledialog available in Silverlight 3.

http://progproblems.blogspot.com/2009/11/saveread-file-from-silverlight-30-in.html

or

http://www.kirupa.com/blend_silverlight/saving_file_locally_pg1.htm

Silverlight has restrictions on what it can do with local files, though I've read that silverlight 4 has some changes.

http://www.wintellect.com/CS/blogs/jprosise/archive/2009/12/16/silverlight-4-s-new-local-file-system-support.aspx

1 Comment

I'll check those out. I'm using sl 3. The deployment will most likely be intranet, but I'm not sure if outside users will need to use it as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.