Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/uploadsource/PhabricatorFileUploadSource.php
<?php | <?php | ||||
abstract class PhabricatorFileUploadSource | abstract class PhabricatorFileUploadSource | ||||
extends Phobject { | extends Phobject { | ||||
private $name; | private $name; | ||||
private $relativeTTL; | private $relativeTTL; | ||||
private $viewPolicy; | private $viewPolicy; | ||||
private $mimeType; | |||||
private $authorPHID; | |||||
private $rope; | private $rope; | ||||
private $data; | private $data; | ||||
private $shouldChunk; | private $shouldChunk; | ||||
private $didRewind; | private $didRewind; | ||||
private $totalBytesWritten = 0; | private $totalBytesWritten = 0; | ||||
private $totalBytesRead = 0; | private $totalBytesRead = 0; | ||||
private $byteLimit = 0; | private $byteLimit = 0; | ||||
Show All 29 Lines | public function setByteLimit($byte_limit) { | ||||
$this->byteLimit = $byte_limit; | $this->byteLimit = $byte_limit; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getByteLimit() { | public function getByteLimit() { | ||||
return $this->byteLimit; | return $this->byteLimit; | ||||
} | } | ||||
public function setMIMEType($mime_type) { | |||||
$this->mimeType = $mime_type; | |||||
return $this; | |||||
} | |||||
public function getMIMEType() { | |||||
return $this->mimeType; | |||||
} | |||||
public function setAuthorPHID($author_phid) { | |||||
$this->authorPHID = $author_phid; | |||||
return $this; | |||||
} | |||||
public function getAuthorPHID() { | |||||
return $this->authorPHID; | |||||
} | |||||
public function uploadFile() { | public function uploadFile() { | ||||
if (!$this->shouldChunkFile()) { | if (!$this->shouldChunkFile()) { | ||||
return $this->writeSingleFile(); | return $this->writeSingleFile(); | ||||
} else { | } else { | ||||
return $this->writeChunkedFile(); | return $this->writeChunkedFile(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | $parameters = array( | ||||
'viewPolicy' => $this->getViewPolicy(), | 'viewPolicy' => $this->getViewPolicy(), | ||||
); | ); | ||||
$ttl = $this->getRelativeTTL(); | $ttl = $this->getRelativeTTL(); | ||||
if ($ttl !== null) { | if ($ttl !== null) { | ||||
$parameters['ttl.relative'] = $ttl; | $parameters['ttl.relative'] = $ttl; | ||||
} | } | ||||
$mime_type = $this->getMimeType(); | |||||
if ($mime_type !== null) { | |||||
$parameters['mime-type'] = $mime_type; | |||||
} | |||||
$author_phid = $this->getAuthorPHID(); | |||||
if ($author_phid !== null) { | |||||
$parameters['authorPHID'] = $author_phid; | |||||
} | |||||
return $parameters; | return $parameters; | ||||
} | } | ||||
private function getChunkEngine() { | private function getChunkEngine() { | ||||
$chunk_engines = PhabricatorFileStorageEngine::loadWritableChunkEngines(); | $chunk_engines = PhabricatorFileStorageEngine::loadWritableChunkEngines(); | ||||
if (!$chunk_engines) { | if (!$chunk_engines) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
Show All 17 Lines |