Ignore:
Timestamp:
2009-01-06T18:40:53+13:00 (15 years ago)
Author:
ak19
Message:

Now plugins provide the option of base64 encoding or url encoding filenames that are to be renamed (when copied into the archives dir). Previously renamed files would always be url-encoded. URL-encoding is the default now for most plugins except MP3Plugin and OggVorbisPlugin, where the default is base64 encoding. Base64 encoding filenames upon renaming them was introduced so that more files that browsers try to open in external applications can open them, since url encoding does not seem to be implemented the same everywhere (for instance, windows media player is unable to handle url-encoded wmv filenames when such files are launched in it through the browser).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/doc.pm

    r17057 r18319  
    4949sub new {
    5050    my $class = shift (@_);
    51     my ($source_filename, $doc_type) = @_;
     51    my ($source_filename, $doc_type, $rename_method) = @_;
    5252
    5353
     
    6767    if (defined $source_filename) {
    6868    $source_filename = &util::filename_within_collection($source_filename);
    69     $self->set_source_filename ($source_filename);
     69    print STDERR "******doc.pm::new(): no file rename method provided\n" unless $rename_method;
     70    $self->set_source_filename ($source_filename, $rename_method);
    7071    }
    7172
     
    144145sub set_source_filename {
    145146    my $self = shift (@_);
    146     my ($source_filename) = @_;
     147    my ($source_filename, $rename_method) = @_;
    147148
    148149    # Since the gsdlsourcefilename element goes into the doc.xml it has
    149150    # to be utf8. However, it should also *represent* the source filename
    150151    # (in the import directory) which may not be utf8 at all.
    151     # For instance, if this meta element (gsdlsourcefilename) will be
    152     # used by other applications that parse doc.xml in order to locate
    153     # gsdlsourcefilename. Therefore, the solution is to URLencode the real
    154     # filename as this is a binary-to-text encoding meaning that the
    155     # resulting string is ASCII (utf8).
    156    
    157 #    print STDERR "******URLencoding the gsdl_source_filename $source_filename ";
    158    
     152    # For instance, if this meta element (gsdlsourcefilename) will be used
     153    # by other applications that parse doc.xml in order to locate
     154    # gsdlsourcefilename. Therefore, the solution is to URLencode or base64
     155    # encode the real filename as this is a binary-to-text encoding meaning
     156    # that the resulting string is ASCII (utf8). Decoding will give the original.
     157   
     158#    print STDERR "******URL/base64 encoding the gsdl_source_filename $source_filename ";
     159
    159160    # URLencode just the gsdl_source_filename, not the directory. Then prepend dir
    160161    my ($srcfilename,$dirname,$suffix)
    161162    = &File::Basename::fileparse($source_filename, "\\.[^\\.]+\$");
    162163#    print STDERR "-> $srcfilename -> ";
    163     $srcfilename = &unicode::url_encode($srcfilename.$suffix);
     164    $srcfilename = &util::rename_file($srcfilename.$suffix, $rename_method);
    164165    $source_filename = &util::filename_cat($dirname, $srcfilename);
    165166#    print STDERR "$source_filename\n";
Note: See TracChangeset for help on using the changeset viewer.