1 | <?php |
||
31 | class FacebookTransferChunk |
||
32 | { |
||
33 | /** |
||
34 | * @var FacebookFile The file to chunk during upload. |
||
35 | */ |
||
36 | private $file; |
||
37 | |||
38 | /** |
||
39 | * @var int The ID of the upload session. |
||
40 | */ |
||
41 | private $uploadSessionId; |
||
42 | |||
43 | /** |
||
44 | * @var int Start byte position of the next file chunk. |
||
45 | */ |
||
46 | private $startOffset; |
||
47 | |||
48 | /** |
||
49 | * @var int End byte position of the next file chunk. |
||
50 | */ |
||
51 | private $endOffset; |
||
52 | |||
53 | /** |
||
54 | * @var int The ID of the video. |
||
55 | */ |
||
56 | private $videoId; |
||
57 | |||
58 | /** |
||
59 | * @param FacebookFile $file |
||
60 | * @param int $uploadSessionId |
||
61 | * @param int $videoId |
||
62 | * @param int $startOffset |
||
63 | * @param int $endOffset |
||
64 | */ |
||
65 | public function __construct(FacebookFile $file, $uploadSessionId, $videoId, $startOffset, $endOffset) |
||
66 | { |
||
67 | $this->file = $file; |
||
68 | $this->uploadSessionId = $uploadSessionId; |
||
69 | $this->videoId = $videoId; |
||
70 | $this->startOffset = $startOffset; |
||
71 | $this->endOffset = $endOffset; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Return the file entity. |
||
76 | * |
||
77 | * @return FacebookFile |
||
78 | */ |
||
79 | public function getFile() |
||
83 | |||
84 | /** |
||
85 | * Return a FacebookFile entity with partial content. |
||
86 | * |
||
87 | * @return FacebookFile |
||
88 | */ |
||
89 | public function getPartialFile() |
||
90 | { |
||
91 | $maxLength = $this->endOffset - $this->startOffset; |
||
92 | |||
93 | return new FacebookFile($this->file->getFilePath(), $maxLength, $this->startOffset); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Return upload session Id |
||
98 | * |
||
99 | * @return int |
||
100 | */ |
||
101 | public function getUploadSessionId() |
||
105 | |||
106 | /** |
||
107 | * Check whether is the last chunk |
||
108 | * |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function isLastChunk() |
||
115 | |||
116 | /** |
||
117 | * @return int |
||
118 | */ |
||
119 | public function getStartOffset() |
||
123 | |||
124 | /** |
||
125 | * Get uploaded video Id |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | public function getVideoId() |
||
133 | } |
||
134 |