Results 1 to 4 of 4

Thread: Finding filename from QNetworkReply

  1. #1
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Finding filename from QNetworkReply

    I am implementing an embedded browser using QWebView in a program, and I am trying to handle the downloading of files. I have everything set up, the files are being downloaded and everything is working as I want it. The only thing I can't figure out is how to find out the filename of the data being downloaded. The filename is generated (almost always) by the servers dynamically when you click on a button or icon. I am getting the data fine in a QNetworkReply, by hooking up to it's finished() signal.
    How do you get the filename the data was sent with? Must you use QNetworkReply, QNetworkRequest or QNetworkManager? I've been debugging just about every attribute of all three classes and I can't find the filename.

    TIA,
    Valheru.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Finding filename from QNetworkReply


  3. #3
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Finding filename from QNetworkReply

    I had been debugging those very functions One would expect QNetworkReply::header( QNetworkRequest::LocationHeader) to contain the filename, but it doesn't. Very infrequently some servers send the filename in QNetworkReply::header( QNetworkRequest::ContentTypeHeader)
    You can, however, reliably retrieve the filename in this case by getting the raw header for Content-Disposition, using QNetworkReply::rawHeader( Content-Disposition ), which returns something along the lines of attachment; filename="filename"

  4. #4
    Join Date
    Nov 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Finding filename from QNetworkReply

    Can you provide a code how did you do that? I haven't found on net any working examples how to override QNetworkReply in conjunction with QNetworkAccessManager. Thnks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.