Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Document store file "Name" - file extension warning/check #686

Closed
listerr opened this issue Dec 30, 2020 · 0 comments
Closed

FR: Document store file "Name" - file extension warning/check #686

listerr opened this issue Dec 30, 2020 · 0 comments

Comments

@listerr
Copy link
Contributor

listerr commented Dec 30, 2020

Is your feature request related to a problem? Please describe.

We recently uploaded all of our member MoU documents into the member document store, replacing the original
ugly filenames like "Signed_memo_2016_v2.pdf" with something nicer and more descriptive like "Member MoU"

Unfortunately it's not obvious in the interface that the "Name" field is also used to generate the download filename, so
if it's not entered as "Member MoU.pdf" then the file doesn't download correctly as the browser doesn't know what to do with it.

I've just noticed that there is explanatory text under this field, but this only appears when you click the "Help" button.

image

Describe the solution you'd like

  • A note/warning under the "Name" field that this must contain the file extension
  • and/or If the name does not contain the file extension of the filename uploaded, warn and/or fix this automatically

Additional context

My simple script to fix broken filenames:

#!/usr/bin/perl

use strict;
use DBI;

# <robl> 2020-11-13
# Turns out that the "Name" in the docstore is used at the filename.
# If it doesn't end in .pdf, the file doesn't download correctly.
# Fix up any name that doesn't end in .pdf that should be .pdf

my $MYSQL_DATABASE           = 'ixpmanager';
my $MYSQL_SERVER             = 'localhost';
my $MYSQL_USER               = 'ixpm_db_user';
my $MYSQL_PASS               = 'ixpm_db_pass';
my $MYSQL_DATA_SOURCE        = "dbi:mysql:$MYSQL_DATABASE:$MYSQL_SERVER";

my $dbh_db = DBI->connect($MYSQL_DATA_SOURCE, $MYSQL_USER, $MYSQL_PASS, {
             RaiseError       => 1,
             PrintError       => 1,
             # AutoCommit     => 0,
             }) or die "Can't connect to mysql db $MYSQL_DATABASE / $MYSQL_SERVER : $DBI::errstr";

           my $sth = $dbh_db->prepare("SELECT id, name, path FROM docstore_customer_files
                                         WHERE
                                          name NOT LIKE '%.pdf' AND
                                          path LIKE '%.pdf'
                                  ") or die "Can't prepare statement: $DBI::errstr";

           $sth->execute( );

                 while (my $row = $sth->fetchrow_hashref) {
                   print "id -> $row->{id} name -> $row->{name}\n";

                   &set_name($row->{id},$row->{name} . '.pdf');
                 }


sub set_name {

        my ($id,$name) = @_;

        return 0 unless ($id);
        return 0 unless ($name);

        my $sql = "UPDATE docstore_customer_files
                   SET name = ?
                   WHERE id = ?";

        my $sth = $dbh_db->prepare($sql);

        $sth->execute($name, $id);

}

@barryo barryo closed this as completed in fef3fb0 Jun 21, 2021
listerr added a commit to listerr/IXP-Manager that referenced this issue Apr 20, 2022
A follow up to: inex#686

Users still seem to be uploading files without extensions, by typing something in the "Name" field, not realising this is used as the actual file name.

Possibly because this is the first field, and it's before the file upload button. If name is not completed, the filename is completed automatically.

File then won't open when downloaded because it has no extension.

- This fix changes "Name" to "File Name" to make it more obvious.
- Validate the file name is "(something).extn"
- Move upload file button before File Name so the user does this bit first. (Then will see the name is filled in for them.)

Can't see a way to make the help text visible by default (it's hidden unless the user clicks the help button.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant