2014-05-03 22:14:00 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Used for serializing files output from jobs
|
|
|
|
*/
|
2014-05-17 10:10:38 +02:00
|
|
|
class ApiFileOutput implements ISerializable
|
2014-05-03 22:14:00 +02:00
|
|
|
{
|
|
|
|
public $fileContent;
|
|
|
|
public $fileName;
|
2014-05-13 14:00:25 +02:00
|
|
|
public $lastModified;
|
|
|
|
public $mimeType;
|
2014-05-03 22:14:00 +02:00
|
|
|
|
|
|
|
public function __construct($filePath, $fileName)
|
|
|
|
{
|
|
|
|
$this->fileContent = file_get_contents($filePath);
|
|
|
|
$this->fileName = $fileName;
|
|
|
|
$this->lastModified = filemtime($filePath);
|
|
|
|
$this->mimeType = mime_content_type($filePath);
|
|
|
|
}
|
2014-05-17 10:10:38 +02:00
|
|
|
|
|
|
|
public function serializeToArray()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
[
|
|
|
|
'name ' => $this->fileName,
|
|
|
|
'modification-time' => $this->lastModified,
|
|
|
|
'mime-type' => $this->mimeType,
|
|
|
|
'content' => base64_encode(gzencode($this->fileContent)),
|
|
|
|
];
|
|
|
|
}
|
2014-05-03 22:14:00 +02:00
|
|
|
}
|