download url with redirection
-
Not tested:
QNetworkAccessManager nam; nam.setRedirectPolicy(QNetworkRequest::SameOriginRedirectPolicy); // set on NAM for all further requests // or: QNetworkRequest req; // this request only req.setAttribute(QNetworkRequest::Attribute::RedirectPolicyAttribute, QNetworkRequest::SameOriginRedirectPolicy);
-
I tested it, reply->error() returns NoError, but I only got an empty file...
-
@skylendar Please show your current code.
-
#include <QtCore/QtCore> #include <QtNetwork/QtNetwork> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QNetworkAccessManager manager; manager.setRedirectPolicy(QNetworkRequest::SameOriginRedirectPolicy); QUrl initialUrl("https://www.dropbox.com/scl/fo/y3naz62gy6f6qfrhquu7u/h/all_ast/ast_100_199/ast100/s100001s.se1?rlkey=ejltdhb262zglm7eo6yfj2940&dl=0"); QNetworkRequest request; request.setUrl(initialUrl); request.setAttribute(QNetworkRequest::Attribute::RedirectPolicyAttribute, QNetworkRequest::SameOriginRedirectPolicy); QNetworkReply *reply = manager.get(request); while (!reply->isFinished()) qApp->processEvents(QEventLoop::WaitForMoreEvents, 500); qDebug() << "erroe:" << reply->error() << "reply size:" << reply->size(); QFile f("se00020s.se1"); f.open(QIODevice::WriteOnly); f.write(reply->readAll()); f.close(); reply->deleteLater(); }
This code is compiled with the usual:
g++ -I /usr/include/qt5 redir1.cpp -lQt5Core -lQt5Network
Before, the code returned an empty file. Now, it contains an html page asking for a dropbox identification, not the wanted file.
-
If your file is not public, you need to add your credentials to authenticate
-
but the file is public. Anyone can download it !
-
@skylendar said in download url with redirection:
but the file is public. Anyone can download it !
I need to enter some kind of credentials...
-
@skylendar Did you at least try visiting the Url from an Incognito window?
-
@skylendar said in download url with redirection:
but the file is public. Anyone can download it !
Maybe you are right, but it seems that DropBox changed its policies and it's required to authenticate somehow...
This thread on DropBox forum says that it's not that easy anymore to share dropbox folders or files with anyone. :(
The link structure changed (type of file often not recognized anymore) and this authentication page was addedMy favourite comment there:
One day someone got up there and decided to change the entire link structure in Dropbox. He didn't think that it might affect a lot of third-party apps, and in fact he didn't think about anything!
Which is very surprising for a serious company like Dropbox.
We already have a group of developers who are considering moving to Amazon's service.
In addition, they do not respond to support emails or opened tickets. Really disappointing, my whole app is just disabled.Just disappointing and infuriating!
(source)
That seems about it! I know, security issue... etc. but I also know how DropBox was used to "quickly share a file" with a defined group or just with everyone who got that link.
-
Ok folks, I thought I made a bug somewhere but this is a dropbox issue. Thx for your help
C.
-
I'm back again, because I was told that the provided url was wrong. with:
https://www.dropbox.com/scl/fo/y3naz62gy6f6qfrhquu7u/h/all_ast/ast100/s100001s.se1?rlkey=ejltdhb262zglm7eo6yfj2940&dl=0
I got the right file with curl but not with the qt test code, but this time, I got this:
.se1 files are supported but something went wrong.
and download is proposed via a sign up.
-
I also added :
request.setRawHeader("User-Agent", "curl/7.54.1");
but this time. my test utility returned:
QNetworkReply::InsecureRedirectError
18/20