The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Object::DOM::File - HTML Object DOM File Class

SYNOPSIS

    use HTML::Object::DOM::File;
    my $file = HTML::Object::DOM::File->new || 
        die( HTML::Object::DOM::File->error, "\n" );

VERSION

    v0.2.0

DESCRIPTION

The File interface provides information about files and allows access to their content.

File objects are generally retrieved from a HTML::Object::DOM::FileList object returned using the <input> files method.

It inherits from Module::Generic::File

PROPERTIES

lastModified

Read-only.

Returns the last modified time of the file, in second since the UNIX epoch (January 1st, 1970 at Midnight), as a Module::Generic::DateTime object. The DateTime object stringifies to the seconds since epoch.

See Mozilla documentation

lastModifiedDate

Read-only.

Returns the last modified date and time of the file referenced by the file object, as a Module::Generic::DateTime object.

See Mozilla documentation

name

Read-only.

Returns the name of the file referenced by the file object.

See Mozilla documentation

webkitRelativePath

Read-only.

Returns the relative file path.

Normally under JavaScript, this works alongside the <input> attribute webkitdirectory:

    <input type="file" webkitdirectory />

allowing a user to select an entire directory instead of just files. So, webkitRelativePath provide the relative file path to that directory uploaded.

See Mozilla documentation

size

Read-only.

Returns the size of the file in bytes.

See Mozilla documentation

type

Read-only.

Returns the MIME type of the file, or undef if it cannot find it.

See Mozilla documentation

METHODS

arrayBuffer

Opens the file as raw data and returns its content as a scalar object.

See Mozilla documentation

slice

Provided with a start and an end as a range, and an optional encoding and this will return that range of data from the file, as a scalar object. If no encoding is provided, this will default to utf-8

If you specify a negative start, it is treated as an offset from the end of the file's data toward the beginning. For example, -10 would be the 10th from last byte in the file data. The default value is 0. If you specify a value for start that is larger than the size of the file, the returned scalar object has size 0 and contains no data.

The end specifies the offset (not the length) of the last byte, without including it, to include in the returned data. If you specify a negative end, it is treated as an offset from the end of the data toward the beginning. For example, -10 would be the 10th from last byte in the file's data. The default value is the file size, i.e. until the end of the file's data.

Returns a new scalar object containing the data in the specified range of bytes of the file.

stream

This opens the file and returns its file handle to read the file's contents. You could also do:

    my $io = $file->open || die( $file->error );

See Mozilla documentation

text

Opens the file in utf-8 and returns its content as a scalar object.

See Mozilla documentation

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mozilla documentation

COPYRIGHT & LICENSE

Copyright(c) 2021 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.