Page MenuHomePhabricator

D18701.id44893.diff
No OneTemporary

D18701.id44893.diff

diff --git a/src/aphront/multipartparser/AphrontMultipartPart.php b/src/aphront/multipartparser/AphrontMultipartPart.php
--- a/src/aphront/multipartparser/AphrontMultipartPart.php
+++ b/src/aphront/multipartparser/AphrontMultipartPart.php
@@ -7,6 +7,8 @@
private $name;
private $filename;
+ private $tempFile;
+ private $byteSize = 0;
public function appendRawHeader($bytes) {
$parser = id(new AphrontHTTPHeaderParser())
@@ -38,10 +40,15 @@
}
public function appendData($bytes) {
+ $this->byteSize += strlen($bytes);
+
if ($this->isVariable()) {
$this->value .= $bytes;
} else {
- throw new Exception(pht('File multipart stuff is not yet supported.'));
+ if (!$this->tempFile) {
+ $this->tempFile = new TempFile(getmypid().'.upload');
+ }
+ Filesystem::appendFile($this->tempFile, $bytes);
}
return $this;
@@ -63,4 +70,27 @@
return $this->value;
}
+ public function getPHPFileDictionary() {
+ if (!$this->tempFile) {
+ $this->appendData('');
+ }
+
+ $mime_type = 'application/octet-stream';
+ foreach ($this->headers as $header) {
+ list($name, $value) = $header;
+ if (strtolower($name) == 'content-type') {
+ $mime_type = $value;
+ break;
+ }
+ }
+
+ return array(
+ 'name' => $this->filename,
+ 'type' => $mime_type,
+ 'tmp_name' => (string)$this->tempFile,
+ 'error' => 0,
+ 'size' => $this->byteSize,
+ );
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 24, 2:34 PM (13 h, 48 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7190309
Default Alt Text
D18701.id44893.diff (1 KB)

Event Timeline