API Client
Public Member Functions | Protected Attributes | List of all members
OneCRM\APIClient\Files Class Reference

Public Member Functions

 __construct (Client $client)
 
 upload ($res, $filename, $content_type= 'application/octet-stream')
 
 download ($model, $id, $res=null)
 
 info ($model, $id)
 

Protected Attributes

 $client
 

Detailed Description

used to upload and download files

Member Function Documentation

OneCRM\APIClient\Files::download (   $model,
  $id,
  $res = null 
)

Downloads a file

Use this method to download a file attached to document, document revision or note.

Parameters
$modelOne of Note, Document, DocumentRevision
$idDocument, revision, or note ID
$resString with file name or stream resource. Optional, if present, downloaded file content will be saved to file or written to stream
Returns
A stream resource with contents of the file
Exceptions
Error
OneCRM\APIClient\Files::info (   $model,
  $id 
)

Retrieves information about a file

Use this method to get information about a file attached to document, document revision or note

Parameters
$modelOne of Note, Document, DocumentRevision
$idDocument, revision, or note ID
Returns
Array with file info
Exceptions
Error
OneCRM\APIClient\Files::upload (   $res,
  $filename,
  $content_type = 'application/octet-stream' 
)

Uploads a temporary file

You can pass file contents using $res parameter in a number of ways:

  • use a string with file content
  • use resource returned by a call to fopen()
  • use a stream resource
Parameters
$resFile content
$filenameFile name
content_typeFile content type
Returns
Temporary file ID.
Exceptions
Error

The documentation for this class was generated from the following file: