Results 1 to 6 of 6

Thread: Finally I managed to upload a file to dropbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2020
    Posts
    27

    Finally I managed to upload a file to dropbox

    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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2020
    Posts
    27

    Re: Finally I managed to upload a file to dropbox

    Where are you guys..Any better solution...!!!

  3. #3

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,645

    Re: Finally I managed to upload a file to dropbox

    Also, as you didn't ask for help (or anything else) in your first post, Mods should have moved it to a different section than this one....:-)
    Sam I am (as well as Confused at times).

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2020
    Posts
    27

    Re: Finally I managed to upload a file to dropbox

    Quote Originally Posted by fafalone View Post
    DropBox has a folder on your computer right... Just copy a file into that folder and it should sync it everywhere.
    I agree with in case you want to upload your files locally..
    But in my case..I need some informations from others users for software registration purpose..

  6. #6
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    485

    Re: Finally I managed to upload a file to dropbox

    Quote Originally Posted by HKcom View Post
    I agree with in case you want to upload your files locally..
    But in my case..I need some informations from others users for software registration purpose..
    I think this method of obtaining user information is not very stable. Why not use a free blog page

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