Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

cj51's avatar
cj51
Helpful | Level 5
9 years ago
Solved

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.

1 Reply

Replies have been turned off for this discussion
  • cj51's avatar
    cj51
    Helpful | Level 5
    9 years ago

    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.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!