Re: Attempting to upload a file to a SharePoint 2010 server



On 06/18/2012 11:47 AM, David C Abrames wrote:
> Hi,
> 
> I am trying to upload document files to a SharePoint 2010 library using
> HTTP PUT.  I found the streaming-test.c file which I am thinking is the
> example I need to use but I can't seem to figure out what the code is
> doing.

The programs in tests/ are generally more about unit/regression testing,
and poking obscure corners of the code in bizarre ways to make sure that
everything still works. They're mostly not good starting points for
doing anything *sane*... (Also, streaming-test is about streaming the
response body, not the request body, so it's all backwards from what you
want to do anyway.)

If you already have the entire contents of the file in memory, then all
you have to do is add it to the SoupMessage's request_body, with
soup_message_set_request(), or soup_message_body_append() or
soup_message_body_append_buffer().

If you want to stream the PUT body so that only part of the file is in
memory at any given time, then it gets a lot trickier. The
"PROPER_STREAMING" test in tests/chunk-test does this, although again,
it's mixed in with various sanity tests and unrelated things. But the
idea is that after the message emits wrote-headers, you write the first
request body chunk, and then after every wrote-body-data signal you
append another chunk. (And you call
soup_message_body_set_accumulate(msg->request_body, FALSE) to tell
libsoup to not save all the chunks to merge them together at the end,
and you probably also want to set the SOUP_MESSAGE_CAN_REBUILD flag to
tell it that if the message gets restarted due to redirection or
authentication, that you're able to start over again.)

-- Dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]