cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Download file by Api ( Files/download ) , no error no file

Download file by Api ( Files/download ) , no error no file

Lukag
Collaborator | Level 8

I try to dowload a file by a Api .

I have no error and a response with "OK" but i don't see the file.

Have i donwloaded it ? where ? can i set up the local directory where save it ? 

This is my code : ( a big doubt is in content-Type ) 

Dim _command As String
_command = "https://content.dropboxapi.com/2/files/download"

Dim Request As HttpWebRequest
Request = HttpWebRequest.Create(_command)
Request.Method = "POST"
Request.KeepAlive = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
Request.ContentType = "application/octet-stream"

Request.UserAgent = "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
ServicePointManager.SecurityProtocol = CType(48, SecurityProtocolType) Or CType(192, SecurityProtocolType) Or CType(768, SecurityProtocolType) Or CType(3072, SecurityProtocolType)
Request.AllowAutoRedirect = True


Request.Headers.Add("Authorization", "Bearer " & _token)
Request.Headers.Add("Dropbox-API-Arg", _parameter)
Try
   Dim Response As HttpWebResponse = Request.GetResponse()

Catch ex As WebException
   Using response = CType(ex.Response, HttpWebResponse)
      Using reader = New IO.StreamReader(response.GetResponseStream())
        _error = reader.ReadToEnd()
      End Using
   End Using
Catch ex As Exception
Throw
End Try

1 Reply 1

Здравко
Legendary | Level 20

@Lukag wrote:

I try to dowload a file by a Api .

I have no error and a response with "OK" but i don't see the file.

Have i donwloaded it ? where ? can i set up the local directory where save it ? 

...


🙂Your code is Ok. You don't need to change anything. It is not the same about understanding what a network stream is!

Your file is downloaded (or in process of download at least) but you expect it to be a file on your local file system. Right? Hm... Error! File object and file stream are different things. 😉 Something you don't clearly understand, as seems. You can direct the file stream you received to a file you want, if you want (as seems it is). It's not something mandatory though. That's it. Add whatever you want in your code, if you want; don't expect it comes somewhere from - not clear where. Also, before continue, get familiar with file and file stream (as terms) - what is common and what different.

Hope this gives direction.

 

PS: It may be helpful to read here and here.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?