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?
ReceiveHTTPFile() with DropBox
ReceiveHTTPFile() with DropBox
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
-
Little John
- Addict

- Posts: 4812
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: ReceiveHTTPFile() with DropBox
Hi TI-994A,
I can confirm your finding.
With the following code (using PB 5.23 LTS x64 on Windows 7)
I'm getting a file with the intended name.
But it's a HTML file with this content:
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().
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$)But it's a HTML file with this content:
When I'm opening that URL with Firefox, then Firefox displays the PDF file as usual.<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>
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
Hi Little John, and thank you for that. You're absolutely right! I wouldn't have thought to read the downloaded file.Little John wrote:...But it's a HTML file...
...It looks to me that on Dropbox there is a redirection...
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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: ReceiveHTTPFile() with DropBox
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
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
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.infratec wrote:...look at my code in the other thread.
It finds out the redirection, but than fail, because PB can not handle https...
You mentioned that PureBasic is not able to handle https; then how did it work before?
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: ReceiveHTTPFile() with DropBox
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
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
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.
On a Windows-System you should try "URLDownloadToFile_(#Null,@_net_page,@_net_file,#Null,#Null)" This should handle also HTTPS.
Re: ReceiveHTTPFile() with DropBox
Thank you, GPI. It works perfectly, even with https (working code with live DropBox link):GPI wrote:...On a Windows-System you should try "URLDownloadToFile_(#Null,@_net_page,@_net_file,#Null,#Null)" This should handle also HTTPS.
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*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
Last edited by TI-994A on Mon Feb 22, 2021 8:41 am, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
-
Little John
- Addict

- Posts: 4812
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: ReceiveHTTPFile() with DropBox
Yes, that's strange.TI-994A wrote:You mentioned that PureBasic is not able to handle https; then how did it work before?
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.

