This should have been checked in with the header bytes change, provides the actual type detection
This commit is contained in:
parent
cb24ac69ab
commit
a1512975b6
@ -42,18 +42,12 @@ class DataUploadEvent extends Event
|
|||||||
assert(is_array($metadata["tags"]));
|
assert(is_array($metadata["tags"]));
|
||||||
assert(is_string($metadata["source"]) || is_null($metadata["source"]));
|
assert(is_string($metadata["source"]) || is_null($metadata["source"]));
|
||||||
|
|
||||||
$this->tmpname = $tmpname;
|
|
||||||
|
|
||||||
$this->metadata = $metadata;
|
$this->metadata = $metadata;
|
||||||
$this->metadata['hash'] = md5_file($tmpname);
|
|
||||||
$this->metadata['size'] = filesize($tmpname);
|
|
||||||
|
|
||||||
// useful for most file handlers, so pull directly into fields
|
$this->set_tmpname($tmpname);
|
||||||
$this->hash = $this->metadata['hash'];
|
|
||||||
|
|
||||||
if($config->get_bool("upload_use_mime")) {
|
if($config->get_bool("upload_use_mime")) {
|
||||||
$this->type = strtolower(get_extension_from_mime($tmpname));
|
$this->set_type(get_extension_from_mime($tmpname));
|
||||||
$this->metadata["extension"] = $this->type;
|
|
||||||
} else {
|
} else {
|
||||||
if(array_key_exists('extension',$metadata)&&!empty($metadata['extension'])) {
|
if(array_key_exists('extension',$metadata)&&!empty($metadata['extension'])) {
|
||||||
$this->type = strtolower($metadata['extension']);
|
$this->type = strtolower($metadata['extension']);
|
||||||
@ -62,6 +56,19 @@ class DataUploadEvent extends Event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function set_type(String $type) {
|
||||||
|
$this->type = strtolower($type);
|
||||||
|
$this->metadata["extension"] = $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_tmpname(String $tmpname) {
|
||||||
|
$this->tmpname = $tmpname;
|
||||||
|
$this->metadata['hash'] = md5_file($tmpname);
|
||||||
|
$this->metadata['size'] = filesize($tmpname);
|
||||||
|
// useful for most file handlers, so pull directly into fields
|
||||||
|
$this->hash = $this->metadata['hash'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UploadException extends SCoreException
|
class UploadException extends SCoreException
|
||||||
|
Loading…
x
Reference in New Issue
Block a user