0

I trying to upload a file with metadata using SharePoint Web Services. The first approach I took is to use the WebRequest/WebResponse objects and then update the metadata using the Lists.asmx - UpdateListItems method. This works just fine but it creates two versions of the file. The second approach I took was to use the Copy.asmx web service and use the CopyIntoItems method which copies the file data along with the metadata. This works fine and creates v 1.0 but when I try to upload the same file with some changes in the metadata (using the Copy.asmx) it does not do update anything. Does anybody came across the same issue or has some other ideas to implement the required functionality.

Thanks, Kiran

2
  • Are you using SharePoint 2007 or 2010? Commented Jun 16, 2011 at 22:37
  • We are using SharePoint 2010. Commented Jun 16, 2011 at 23:15

1 Answer 1

1

This might be a bit of topic (sorry) but I'd like to advice you to a real timesaving shortcut when working with SharePoint remotely, http://www.bendsoft.com/net-sharepoint-connector/

It enables you to work with SharePoint lists and document libraries with SQL and stored procedures.

Uploading a file as a byte array

...
string sql = "CALL UPLOAD('Shared Documents', 'Images/Logos/mylogo.png', @doc)";

byte[] data = System.IO.File.ReadAllBytes("C:\\mylogo.png");
SharePointCommand cmd = new SharePointCommand(sql, myOpenConnection);
cmd.Parameters.Add("@doc", data);

cmd.ExecuteNonQuery();
...

Upload stream input

using (fs == System.IO.File.OpenRead("c:\\150Mb.bin")) {
    string sql = "CALL UPLOAD('Shared Documents', '150Mb.bin', @doc)";
    SharePointCommand cmd = new SharePointCommand(sql, myOpenConnection);
    cmd.Parameters.Add("@doc", fs);
    cmd.ExecuteNonQuery();
}

There are quite a few methods to simplify remote document management

UPLOAD(lisname, filename, data)
DOWNLOAD(listname, filename)
MOVE(listname1, filename1, listname2, filename2)
COPY(listname1, filename1, listname2, filename2)
RENAME(listname, filename1, filename2)
DELETE(listname, filename)
CREATEFOLDER(listname, foldername)
CHECKOUT(list, file, offline, lastmodified)
CHECKIN(list, file, comment, type)
UNDOCHECKOUT(list, file)

Cheers

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

1 Comment

I don't really want to spend money on the tool you are describing, but I gotta say - I really like alternative approaches to solving the problem. This tool totally side-steps all the web services authentication stuff (assuming using SP Web Services)...

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.