Chilkat VBScript DropBox file upload writes a zero byte file

26 views Asked by At

So, this seems to be a problem regardless of the scripting/programming language but I am using Chilkat's REST and Stream objects for uploading files to Dropbox and while I have gotten it to appear to work, the file length is zero bytes.

    set rest = Server.CreateObject("Chilkat_9_5_0.Rest")

    success = rest.Connect("content.dropboxapi.com",443,1,1)
    If (success <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
        Response.End
    End If

    success = rest.AddHeader("Content-Type","application/octet-stream")
    success = rest.AddHeader("Authorization","Bearer $Authtoken")

    set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
    success = json.AppendString("path","/VCARQB/test.xlsx")
    success = json.AppendString("mode","add")
    success = json.AppendBool("autorename",1)
    success = json.AppendBool("mute",0)
    success = rest.AddHeader("Dropbox-API-Arg",json.Emit())

    set fileStream = Server.CreateObject("Chilkat_9_5_0.Stream")
    fileStream.SourceFile = "/files/test.xlsx"

    responseStr = rest.FullRequestStream("POST","/2/files/upload",fileStream)
    If (rest.LastMethodSuccess <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
        Response.End
    End If

    set jsonResp = Server.CreateObject("Chilkat_9_5_0.JsonObject")
    jsonResp.EmitCompact = 0
    success = jsonResp.Load(responseStr)

The file is only 6k, the authorization and permissions work correctly (that was my first headache) but nothing else happens.

0

There are 0 answers