You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

cj51's avatar
cj51
Helpful | Level 5
8 years ago

Uploaded ZIP file is corrupted

After uploading a compressed ZIP file cannot be opened by the 7Zip or WinZip program on my desktop PC. I can open the original file but after I upload it using the sample code below, the file is about 90KB larger and corrupted.  Does anyone know what I am doing wrong?

Thank you in advance.

cj51

---------------------SAMPLE VBA CODE-----------------------

Function ReadBinary(sFile As String) As Byte()
    Dim nFile       As Integer
    ReadBinary = ""
    nFile = FreeFile
    Open sFile For Binary Access Read As #nFile
    If LOF(nFile) > 0 Then
        ReDim ReadBinary(0 To LOF(nFile) - 1)
        Get nFile, , ReadBinary
    End If
    Close #nFile
End Function
------------------ API SYNTAX STARTS HERE ---------------
strFile = ReadBinary(FileName)
arg = "{""path"":" & DQ & "/File requests/StatusLog/" & DropBox_FileName & DQ & "," &     """mode"":""overwrite"",""autorename"": true,""mute"":true}"

req.Open "POST", "https://content.dropboxapi.com/2/files/upload", False
req.setRequestHeader "Authorization", "Bearer <yadayada"
req.setRequestHeader "Content-Type", "application/octet-stream"
req.setRequestHeader "Content-length", Len(strFile)
req.setRequestHeader "Dropbox-API-Arg", arg
req.setRequestHeader "User-Agent", "api-explorer-client"
req.send strFile

  • PROBLEM SOLVED! -  I replaced the send strFile with send ReadBinary function, deleted the strFile = ReadBinnary line and replaced the Len(strFile) with FileLen("NAME OF INPUT FILE').  This issue can be closed.

  • cj51's avatar
    cj51
    Helpful | Level 5

    PROBLEM SOLVED! -  I replaced the send strFile with send ReadBinary function, deleted the strFile = ReadBinnary line and replaced the Len(strFile) with FileLen("NAME OF INPUT FILE').  This issue can be closed.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,884 PostsLatest Activity: 32 minutes ago
326 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!