Re: [pgAdmin4][runtime]: Download feature in runtime - Mailing list pgadmin-hackers

From Dave Page
Subject Re: [pgAdmin4][runtime]: Download feature in runtime
Date
Msg-id CA+OCxozY73dR+0OrOrO-urNHaUOJBXjUJB1q31-oMRyM4jXoyg@mail.gmail.com
Whole thread Raw
In response to [pgAdmin4][runtime]: Download feature in runtime  (Neel Patel <neel.patel@enterprisedb.com>)
Responses Re: [pgAdmin4][runtime]: Download feature in runtime  (Neel Patel <neel.patel@enterprisedb.com>)
List pgadmin-hackers
Hi

On Thu, Jun 30, 2016 at 10:42 AM, Neel Patel
<neel.patel@enterprisedb.com> wrote:
> Hi,
>
> Please find attached patch file for initial version of download file in
> runtime application.

I've attached an update with some improved messages, and setting the
progress dialogue to be modal (seeing as we cannot have multiple
downloads, and it's easy to lose the dialogue).

> With this patch, we have implemented two features.
>
> Feature 1 :- Normal "Download file" from runtime application
>
> Previously "Download file" was not implemented in runtime application.
> With this patch file, we have handled Qt signal for download file properly.

This seems to work fine. I did get one crash (after I cancelled a
download, then tried it again), but I couldn't reproduce that.

> Feature 2 :-   "download" attribute support for 'a' tag for client side
> download
>
> As per our knowledge, webkit has not implemented the download attribute at
> 'a' tag.
> Currently it shows under development from below link.
>
> https://bugreports.qt.io/browse/QTBUG-47732
>
> We did not found any signal in Qt for download attribute feature but to
> implement this feature in runtime application, we added one workaround to
> make it work with download CSV file.
>
> When we click on download buttons, we are getting Qt signal "urlLinkClicked"
> and in that url we are finding "data:text/csv" from encoded URL generated
> from sqleditor. Once we found that tag then we are decoding the csv data and
> writing to file.
>
> Is that right approach ? Should we add our own custom mime-type to header ?
> Let us know your thoughts on this feature.

This doesn't work so well, for a number of reasons:

1) QT Creator is complaining that your regexp contains an invalid
escape sequence (line 546).

2) The default file name seems to be the entire data blob. I would
suggest making the file name "download.csv" if we don't know anything
better. The "csv" part should be taken from the mime type (see below)

3) Should we handle all "data:" downloads in this way? Taking the file
type and default extension from the mimetype offered.

4) When I change the filename the data is properly saved, but then I
get a confirmation message that still has the full data blob as the
filename.

5) It somehow seems to have let me save files with forward slashes in
the name. See attachment.

6) I get all sorts of weird redrawing on the screen when downloading a
data blob. I suspect it's because the filename (which is still the
entire data blob) is shown on the progress dialogue.

Thanks.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Require passwords to be at least 6 chars long in setu
Next
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Beta 2.1 - a favour for our friends in QA.