Results 1 to 5 of 5

Thread: Problems with http PUT to sharepoint server

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    5

    Problems with http PUT to sharepoint server

    Ultimately I want to upload a file to a sharepoint document library. This looks extremely easy and trivial but I haven't written any VB in about 10 years, so it's kicking my strASS

    I have tried looking into using the web services for this, but all of the solutions posted are incomplete, so I've punted and gone after the http put methods.

    I found this vbscript which works very well, tested on files up to 23MB and it works great.

    --snip--
    'Use this function call to upload a single file
    WebUploadFile "C:\filename.any", "http://server/library/filename.any", "domain\user", "password"

    '====================== WebDAV upload single file
    Function WebUploadFile (file, url, user, pass)
    Dim objXMLHTTP
    Dim objADOStream
    Dim arrbuffer
    Set objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open
    objADOStream.Type = 1
    objADOStream.LoadFromFile file
    arrbuffer = objADOStream.Read()
    Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    objXMLHTTP.open "PUT", url, False, user, pass
    objXMLHTTP.send arrbuffer
    End Function

    --snip--

    I have been trying to convert this to some kind of VB2008 and I've gotten to here:

    --snip--
    Module SharePointPutTestFunctions
    Function WebUploadFile(ByVal file As String, ByVal url As String, ByVal user As String, ByVal pass As String) As String
    Dim objXMLHTTP
    Dim objADOStream
    Dim arrbuffer As Object
    Dim strresponse
    objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open()
    objADOStream.Type = 1
    objADOStream.LoadFromFile(file)
    arrbuffer = objADOStream.Read()
    objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    strresponse = objXMLHTTP.open("PUT", url, False, user, pass)
    strresponse = objXMLHTTP.send(arrbuffer)
    MsgBox(strresponse)
    WebUploadFile = "Success - maybe...no real error trapping in here currently, just a return value to be complete"
    End Function
    End Module
    --snip--

    (feel free to giggle at my 'back in the day' tendencies with VB, I'm just trying to get the error list box to shut up ).

    In any case, this works (or seems to work) but the files are always 0bytes. I'm assuming there is something about how these variables are automatically typed in vbs that I need to be explicit about in VB2008.

    Any guidance or links appreciated - if anyone has some pretty clear examples or links about doing this with the web-service that would be better, but I'll take what I can get.

    Many thanks!

    Bif

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Problems with http PUT to sharepoint server

    so you are trying to make a windows forms app that uploads to sharepoint? or are you actually trying to do this in a web app?

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    5

    Re: Problems with http PUT to sharepoint server

    Quote Originally Posted by kleinma View Post
    so you are trying to make a windows forms app that uploads to sharepoint? or are you actually trying to do this in a web app?
    Many thanks for the prompt reply!

    I'm trying to make a windows forms app that uploads to sharepoint. I'm using Visual Basic 2008 Express Edition.

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    5

    Re: Problems with http PUT to sharepoint server

    This seems like a pretty straightforward operation/question - does anyone have any links or suggestions?...is this too basic a question for this area?...any other resources appreciated. Thanks!

  5. #5
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Problems with http PUT to sharepoint server

    *bump*

    I am now in need of this exact functionality.
    Uploading to a Sharepoint DocumentLibrary from a Windows Form

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width