Page 1 of 1
ReceiveHTTPFile() with DropBox
Posted: Thu Sep 18, 2014 2:06 pm
by TI-994A
I've been using PureBasic's
ReceiveHTTPFile() function in many of the examples that I've posted here, to download media files from DropBox. Here are some of those examples:
*
hyperlinking images
*
playing MOD/XM files
*
converting images to monochrome
I've tested, and the links are still active and works from the browser.
However, the
ReceiveHTTPFile() function seems no longer able to download from DropBox. Did they change some protocol to disallow this or something?
Re: ReceiveHTTPFile() with DropBox
Posted: Thu Sep 18, 2014 6:07 pm
by Little John
Hi TI-994A,
I can confirm your finding.
With the following code (using PB 5.23 LTS x64 on Windows 7)
Code: Select all
url$ = "https://dl.dropboxusercontent.com/u/6548674/davechild_regular-expressions.pdf"
file$ = GetTemporaryDirectory() + GetFilePart(GetURLPart(url$, #PB_URL_Path))
InitNetwork()
Debug ReceiveHTTPFile(url$, file$)
I'm getting a file with the intended name.
But it's a HTML file with this content:
<html>
<head><title>Found</title></head>
<body>
<h1>Found</h1>
<p>The resource was found at <a href="
https://dl.dropboxusercontent.com/u/654 ... ons.pdf</a>;
you should be redirected automatically.
<!-- --></p>
<hr noshade>
<div align="right">WSGI Server</div>
</body>
</html>
When I'm opening that URL with Firefox, then Firefox displays the PDF file as usual.
Downloading a file from my own website with ReceiveHTTPFile() works correctly.
It looks to me that on Dropbox there is a redirection, which can't be handled by PB's ReceiveHTTPFile().
Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 6:17 am
by TI-994A
Little John wrote:...But it's a HTML file...
...It looks to me that on Dropbox there is a redirection...
Hi Little John, and thank you for that. You're absolutely right! I wouldn't have thought to read the downloaded file.
It does seem that they've added a redirection layer for some reason. I've tried to find a workaround, but unfortunately to no success.
Thanks again.

Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 7:13 am
by infratec
Hi,
look at my code in the other thread.
It finds out the redirection, but than fail, because PB can not handle https.
If you modify the code, you can build a procedure wich returns the redirection address.
Bernd
Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 8:20 am
by TI-994A
infratec wrote:...look at my code in the other thread.
It finds out the redirection, but than fail, because PB can not handle https...
Hi Bernd, and thank you. I tried out your code, and it was able to extract the link from the downloaded HTML code; but it was the same one, and not some redirection link.
You mentioned that PureBasic is not able to handle
https; then how did it work before?

Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 8:41 am
by infratec
Hi,
ReadHTTPFile() seams to use the browser engine of the OS.
So https works with ReadHTTPFile().
But that's not PB.
I changed my code to get the redirection, but it only gets back the https path.
And than it has to stop.
But if I look at Little Johns example, I can not detect a difference between the URLs.
Maybe they install a cookie at the first request and check at the second request if the cookie is available.
But unfortunately this does not help you
Bernd
Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 4:21 pm
by GPI
I had many problems with ReceiveHTTPFile(), for example that only 1 or 2 KB of a 144kb-File was downloaded.
On a Windows-System you should try "URLDownloadToFile_(#Null,@_net_page,@_net_file,#Null,#Null)" This should handle also HTTPS.
Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 5:55 pm
by TI-994A
GPI wrote:...On a Windows-System you should try "URLDownloadToFile_(#Null,@_net_page,@_net_file,#Null,#Null)" This should handle also HTTPS.
Thank you, GPI. It works perfectly, even with
https (working code with live DropBox link):
Code: Select all
URL.s = "https://www.dropbox.com/s/ewrlaf3vlobb0k0/googleLogo.jpg?dl=1"
fileName.s = GetTemporaryDirectory() + "googleLogo.jpg"
error = URLDownloadToFile_(#Null, @URL, @fileName, #Null, #Null)
If Not error
RunProgram(fileName)
EndIf
The sad thing is, PureBasic's
ReceiveHTTPFile() function is supposed to be cross-platform.
*CODE UPDATE (22/2/2021): Changes in Dropxox's file server structures have rendered direct downloads with the URLDownloadToFile() Windows API function ineffective.
As of this post, Dropbox's file links can once again be downloaded with the
ReceiveHTTPFile() function.
Code: Select all
InitNetwork()
fileName.s = GetTemporaryDirectory() + "googleLogo.jpg"
success = ReceiveHTTPFile("https://www.dropbox.com/s/ewrlaf3vlobb0k0/googleLogo.jpg?dl=1", fileName)
If success
RunProgram(fileName)
EndIf
Re: ReceiveHTTPFile() with DropBox
Posted: Fri Sep 19, 2014 6:47 pm
by Little John
TI-994A wrote:You mentioned that PureBasic is not able to handle
https; then how did it work before?

Yes, that's strange.
In the past, there have been feature requests for ReceiveHTTPFile() to support HTTPS, e.g.
here. If these requests are valid, this would mean by implication that ReceiveHTTPFile() did/does not support HTTPS. Unfortunately, in the
documentation of ReceiveHTTPFile(), there is no single word about HTTPS.
I would highly appreciate it, if Fred or Freak would write an official statement, whether or not ReceiveHTTPFile() currently does support HTTPS.