From 336f6ee04ddf9820d347ba9c37065b39d4162476 Mon Sep 17 00:00:00 2001 From: Michael Calcinai Date: Tue, 6 Oct 2015 07:53:21 +1300 Subject: [PATCH] Adds feature-100 - attachemtnes from binary/memory --- src/XeroPHP/Models/Accounting/Attachment.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/XeroPHP/Models/Accounting/Attachment.php b/src/XeroPHP/Models/Accounting/Attachment.php index 0ee73ab9..2d9a092b 100644 --- a/src/XeroPHP/Models/Accounting/Attachment.php +++ b/src/XeroPHP/Models/Accounting/Attachment.php @@ -116,6 +116,23 @@ public static function createFromLocalFile($file_name, $mime_type = null){ return $instance; } + + public static function createFromBinary($data, $file_name, $mime_type){ + + $content_length = strlen($data); + + $instance = new self(); + $instance->fromStringArray(array( + 'MimeType' => $mime_type, + 'ContentLength' => $content_length, + 'FileName' => $file_name + )); + + $instance->content = $data; + + return $instance; + } + /** * @return string */