|
dolibarr
13.0.2
|
API class for receive files. More...
Inheritance diagram for Documents:
Collaboration diagram for Documents:Public Member Functions | |
| __construct () | |
| Constructor. | |
| index ($modulepart, $original_file= '') | |
| Download a document. More... | |
| builddoc ($modulepart, $original_file= '', $doctemplate= '', $langcode= '') | |
| Build a document. More... | |
| getDocumentsListByElement ($modulepart, $id=0, $ref= '', $sortfield= '', $sortorder= '') | |
| Return the list of documents of a dedicated element (from its ID or Ref) More... | |
| post ($filename, $modulepart, $ref= '', $subdir= '', $filecontent= '', $fileencoding= '', $overwriteifexists=0, $createdirifnotexists=1) | |
| Return a document. More... | |
| delete ($modulepart, $original_file) | |
| Delete a document. More... | |
Public Member Functions inherited from DolibarrApi | |
| __construct ($db, $cachedir= '', $refreshCache=false) | |
| Constructor. More... | |
Private Member Functions | |
| _validate_file ($data) | |
| Validate fields before create or update object. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from DolibarrApi | |
| _cleanObjectDatas ($object) | |
| Executed method when API is called without parameter. More... | |
| _checkFilters ($sqlfilters) | |
| Return if a $sqlfilters parameter is valid. More... | |
Static Protected Member Functions inherited from DolibarrApi | |
| static | _checkAccessToResource ($resource, $resource_id=0, $dbtablename= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid') |
| Check user access to a resource. More... | |
| static | _forge_criteria_callback ($matches) |
| Function to forge a SQL criteria. More... | |
API class for receive files.
protected ,external}
Definition at line 33 of file api_documents.class.php.
|
private |
Validate fields before create or update object.
| array | $data | Array with data to verify |
| RestException |
Definition at line 823 of file api_documents.class.php.
| Documents::builddoc | ( | $modulepart, | |
$original_file = '', |
|||
$doctemplate = '', |
|||
$langcode = '' |
|||
| ) |
Build a document.
Test sample 1: { "modulepart": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }.
| string | $modulepart | Name of module or area concerned by file download ('invoice', 'order', ...). |
| string | $original_file | Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). |
| string | $doctemplate | Set here the doc template to use for document generation (If not set, use the default template). |
| string | $langcode | Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language). |
| RestException | 500 |
| RestException | 501 |
| RestException | 400 |
| RestException | 401 |
| RestException | 404 |
PUT /builddoc
Definition at line 139 of file api_documents.class.php.
References db, dol_check_secure_access_document(), dol_mimetype(), and dol_osencode().
| Documents::delete | ( | $modulepart, | |
| $original_file | |||
| ) |
Delete a document.
| string | $modulepart | Name of module or area concerned by file download ('product', ...) |
| string | $original_file | Relative path with filename, relative to modulepart (for example: PRODUCT-REF-999/IMAGE-999.jpg) |
| RestException | 400 |
| RestException | 401 |
| RestException | 404 |
DELETE /
Definition at line 757 of file api_documents.class.php.
References dol_check_secure_access_document(), dol_osencode(), and dol_syslog().
| Documents::getDocumentsListByElement | ( | $modulepart, | |
$id = 0, |
|||
$ref = '', |
|||
$sortfield = '', |
|||
$sortorder = '' |
|||
| ) |
Return the list of documents of a dedicated element (from its ID or Ref)
| string | $modulepart | Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) |
| int | $id | ID of element |
| string | $ref | Ref of element |
| string | $sortfield | Sort criteria ('','fullname','relativename','name','date','size') |
| string | $sortorder | Sort order ('asc' or 'desc') |
| RestException | 400 |
| RestException | 401 |
| RestException | 404 |
| RestException | 500 |
GET /
Definition at line 265 of file api_documents.class.php.
References db, dol_dir_list(), dol_sanitizeFileName(), and get_exdir().
| Documents::index | ( | $modulepart, | |
$original_file = '' |
|||
| ) |
Download a document.
Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead).
| string | $modulepart | Name of module or area concerned by file download ('facture', ...) |
| string | $original_file | Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
| RestException | 400 |
| RestException | 401 |
| RestException | 404 |
GET /download
Definition at line 69 of file api_documents.class.php.
References dol_check_secure_access_document(), dol_mimetype(), dol_osencode(), and dol_syslog().
| Documents::post | ( | $filename, | |
| $modulepart, | |||
$ref = '', |
|||
$subdir = '', |
|||
$filecontent = '', |
|||
$fileencoding = '', |
|||
$overwriteifexists = 0, |
|||
$createdirifnotexists = 1 |
|||
| ) |
Return a document.
| int | $id | ID of document |
| RestException | Upload a file. |
Test sample for invoice: { "filename": "mynewfile.txt", "modulepart": "invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }.
| string | $filename | Name of file to create ('FA1705-0123.txt') |
| string | $modulepart | Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) |
| string | $ref | Reference of object (This will define subdir automatically and store submited file into it) |
| string | $subdir | Subdirectory (Only if ref not provided) |
| string | $filecontent | File content (string with file content. An empty file will be created if this parameter is not provided) |
| string | $fileencoding | File encoding (''=no encoding, 'base64'=Base 64) |
| int | $overwriteifexists | Overwrite file if exists (1 by default) |
| int | $createdirifnotexists | Create subdirectories if the doesn't exists (1 by default) |
| RestException | 400 |
| RestException | 401 |
| RestException | 404 |
| RestException | 500 |
POST /upload
Definition at line 555 of file api_documents.class.php.
References db, dol_basename(), dol_check_secure_access_document(), dol_delete_file(), dol_is_dir(), dol_is_file(), dol_mkdir(), dol_move(), dol_sanitizeFileName(), dol_sanitizePathName(), and get_exdir().