Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15583

Finally I managed to upload a file to dropbox

$
0
0
After so much hassle I was able to find a way to upload a file to Dropbox

Code:

Private Sub Form_Load()
access_token = your_token
vardir = your_file_to_upload
End Sub

Private Sub Command1_Click()
    Dim arg As String
    Dim result
   
    result = ReadBinary(vardir)
   
   
'    varfile = "\/your_folder_in_dropbox\/name_and_extension_of_the_saved_file"
     
'    arg = "{""path"":""" & varfile & """,""mode"":""add"",""autorename"":false,""mute"":true}"
   
    arg = "{""path"":""" & varfile & """,""mode"":""overwrite"",""autorename"":false,""mute"":true}"
   
    Set req = CreateObject("WINHTTP.WinHTTPRequest.5.1")
   
    req.Open "POST", "https://content.dropboxapi.com/2/files/upload", False
    req.setRequestHeader "Authorization", "Bearer " & access_token      '
    req.setRequestHeader "Content-Type", "application/octet-stream"

    req.setRequestHeader "Dropbox-API-Arg", arg
    req.setRequestHeader "User-Agent", "api-explorer-client"
    req.send (result)
   
    If req.Status = 200 Then
        Debug.Print req.responseText
    Else
        Debug.Print req.responseText
       
    End If

Function ReadBinary(ByVal sFile As String) As Byte()
    Dim b() As Byte
    Open sFile For Binary As #1
    ReDim b(FileLen(sFile ) - 1)
    Get #1, , b
    Close #1
    ReadBinary= b
End Function
End Sub


Go to Dropbox console and do your setting there

Viewing all articles
Browse latest Browse all 15583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>