summaryrefslogtreecommitdiff
path: root/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php')
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php40
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php
index f8b9905..3c1536d 100644
--- a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php
+++ b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookFile.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
@@ -38,6 +38,16 @@ class FacebookFile
protected $path;
/**
+ * @var int The maximum bytes to read. Defaults to -1 (read all the remaining buffer).
+ */
+ private $maxLength;
+
+ /**
+ * @var int Seek to the specified offset before reading. If this number is negative, no seeking will occur and reading will start from the current position.
+ */
+ private $offset;
+
+ /**
* @var resource The stream pointing to the file.
*/
protected $stream;
@@ -46,12 +56,16 @@ class FacebookFile
* Creates a new FacebookFile entity.
*
* @param string $filePath
+ * @param int $maxLength
+ * @param int $offset
*
* @throws FacebookSDKException
*/
- public function __construct($filePath)
+ public function __construct($filePath, $maxLength = -1, $offset = -1)
{
$this->path = $filePath;
+ $this->maxLength = $maxLength;
+ $this->offset = $offset;
$this->open();
}
@@ -98,7 +112,7 @@ class FacebookFile
*/
public function getContents()
{
- return stream_get_contents($this->stream);
+ return stream_get_contents($this->stream, $this->maxLength, $this->offset);
}
/**
@@ -112,6 +126,26 @@ class FacebookFile
}
/**
+ * Return the path of the file.
+ *
+ * @return string
+ */
+ public function getFilePath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * Return the size of the file.
+ *
+ * @return int
+ */
+ public function getSize()
+ {
+ return filesize($this->path);
+ }
+
+ /**
* Return the mimetype of the file.
*
* @return string