NAME

File::ArchivableFormats - Be able to select archivable formats

VERSION

version 1.8

SYNOPSIS

use File::ArchivableFormats;

my $archive = File::ArchivableFormats->new();

open my $fh, '<', 'path/to/file';

my $result_fh = $archive->identify_from_fh($fh);

my $result_path = $archive->identify_from_path('/path/to/file');

DESCRIPTION

This module identifies filetypes and tells you whether they are considered archivable by various institutes. This is done via a plugin mechanism.

ATTRIBUTES

METHODS

parse_extension

Parses the filename and returns the extension. Uses "fileparse" in File::Basename

identify_from_fh

Identify the file from a file handle. Please note that this does not work with a File::Temp filehandle.

Returns a data structure like this:

{
    # DANS is the Prefered format list
    'DANS' => {
        # Types tell  you something about why something is on the
        # preferred format list
        'types' => [
            'Plain text (Unicode)',
            'Plain text (Non-Unicode)',
            'Statistical data (data (.csv) + setup)',
            'Raspter GIS (ASCII GRID)',
            'Raspter GIS (ASCII GRID)'
        ],
        # The extensions by which belongs to the mime type/file
        'allowed_extensions' => ['.asc', '.txt'],
        # Boolean which tells you if the file is archivable and
        # therfore preferred.
        'archivable'         => 1
    },
    'mime_type' => 'text/plain'
};

identify_from_path

Identify the file from path/filename.

identify_from_mimetype

Identify based on the mimetype

installed_drivers

Returns an array with all the installed plugins.

SEE ALSO

File::MimeInfo::Magic
IANA

http://www.iana.org/assignments/media-types/media-types.xhtml

http://www.iana.org/assignments/media-types/application.csv

AUTHOR

Wesley Schwengle <wesley@mintlab.nl>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Mintlab BV.

This is free software, licensed under:

The European Union Public License (EUPL) v1.1