Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create multiple file upload application(Client Object Modal) which upload the multiple document in the specific(selected) document library with the meta data(custom properties in library). is it possible to create application like this type of application ? if it is possible then how ?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Yes. I think you need to use an HTTP PUT to send the file to the server. Then, having sent it, you'll need to retrieve and set it's details using the client object model.

To upload a file, you can use something like:

WebRequest request = WebRequest.Create( "http://somedestination" + "/" + filename);
ICredentials creds;
//Set your credentials
request.Credentials = creds;
request.Method = "PUT";
byte[] buffer = new byte[1024];
using (Stream stream = request.GetRequestStream())
{
    using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read))
    {
        for (int i = fs.Read(buffer, 0, buffer.Length); i > 0; i = fs.Read(buffer, 0, buffer.Length))
        {
            stream.Write(buffer, 0, i);
        }
    }
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.