---
name: "LedgerSMB::File"
section: "3pm"
platform: "linux"
package: "ledgersmb"
version: "1.3.40-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/LedgerSMB::File"
---

# LedgerSMB::File(3pm)

Provides routines for managing file attachments.

## NAME

LedgerSMB::File - Provides routines for managing file attachments.

## SYNPSIS

This provides routines for managing file attachments.  Subclasses may be used to provide functionality for specific types of file attachments.

## PROPERTIES/ACCESSORS

- attached\_by\_id

  Entity id of the individual who attached the file.

- attached\_by

  Entity name of individual who attached file

- attached\_at

  Timestamp of attachment point.

- content

  This stores the binary content of the file.

- mime\_type\_id

  ID of the MIME type.  Undef if unknown.

- mime\_type\_text

  Standard text code of the MIME type

- file\_name

  File name, user specified

- description

  Description, user specified

- id

  ID of file.  undef if unknown

- ref\_key

  Referential key for the file to attach to.

- reference

  Reference control code (text string) for attached financial database object.

- file\_class

  ID of the file class.

- src\_class

  ID of class of the original attachment point (for a link)

- file\_path

  Path, relative to `$LedgerSMB::tempdir`, where file data is stored (for LaTeX use of attached images).

- dbobject

  Object for db interface.

- sizex

  X axis dimensions, if Image::Size is installed and file is image (only on files retrieved for invoices).

- sizey

  Y axis dimensions, if Image::Size is installed and file is image (only on files retrieved for invoices).

- x\_info

  A hash for extended information

  Note additionally the `$self` hashref contains the basic required attributes for DBObject, namely dbh, \_roles, and \_locale.

## METHODS

- new

  Returns a blessed object

- to\_hashref

  Returns a hashref of properties for the object.

- new\_dbobject

  `$file`-\>new\_dbobject({base =\> (LedgerSMB \| LedgerSMB::Form),  locale =\> LedgerSMB::Locale});

  Creates a new file object.  Locale only needs to be specified when using LedgerSMB::Form objects since these are not included.

  Returns 0 on success.

  Error codes on exit (OR'd):

  1:  No database handle included 2:  No locale handle included 4:  Invalid base.

  In most cases when working with new code it is simpler to just

  `$file`-\>dbobject(LedgerSMB::DBObject-\>new({base =\> `$request`});

- get\_mime\_type

  Sends the textual representation of the MIME type.  If not set, retrieves and sets it.

- set\_mime\_type

  Sets the mipe\_type\_id from the mime\_type\_text

- detect\_type

  Auto-detects the type of the file.  Not yet implemented

- get

  Retrives a file.  ID and file\_class properties must be set.

- get\_for\_template({ref\_key =\> int, file\_class =\> int})

  Returns file data for invoices for embedded images, except that content is set to a directive relative to tempdir where these files are stored.

- list({ref\_key =\> int, file\_class =\> int})

  Lists files directly attached to the object.

- list\_links({ref\_key =\> int, file\_class =\> int})

  Lists the links directly attached to the object.

- exec\_method

  Provides a compatible interface to LedgerSMB::DBObject::exec\_method

- merge(hashref)

  Merges in specific attributes from the ref.

- *commit()*

  Returns the value of DBI-\>commit

## COPYRIGHT

Copyright (C) 2011 The LedgerSMB Core Team

This file is licensed under the Gnu General Public License version 2, or at your option any later version.  A copy of the license should have been included with your software.
