Make base64 decoding optional for uploaded data
This commit is contained in:
@@ -307,31 +307,35 @@ abstract class FileModel extends Base
|
|||||||
* Handle file upload (base64 encoded content)
|
* Handle file upload (base64 encoded content)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @param string $original_filename
|
* @param string $originalFilename
|
||||||
* @param string $blob
|
* @param string $data
|
||||||
* @return bool|integer
|
* @param bool $isEncoded
|
||||||
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
public function uploadContent($id, $original_filename, $blob)
|
public function uploadContent($id, $originalFilename, $data, $isEncoded = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = base64_decode($blob);
|
if ($isEncoded) {
|
||||||
|
$data = base64_decode($data);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
|
$this->logger->error(__METHOD__.': Content upload with no data');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$destination_filename = $this->generatePath($id, $original_filename);
|
$destinationFilename = $this->generatePath($id, $originalFilename);
|
||||||
$this->objectStorage->put($destination_filename, $data);
|
$this->objectStorage->put($destinationFilename, $data);
|
||||||
|
|
||||||
if ($this->isImage($original_filename)) {
|
if ($this->isImage($originalFilename)) {
|
||||||
$this->generateThumbnailFromData($destination_filename, $data);
|
$this->generateThumbnailFromData($destinationFilename, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->create(
|
return $this->create(
|
||||||
$id,
|
$id,
|
||||||
$original_filename,
|
$originalFilename,
|
||||||
$destination_filename,
|
$destinationFilename,
|
||||||
strlen($data)
|
strlen($data)
|
||||||
);
|
);
|
||||||
} catch (ObjectStorageException $e) {
|
} catch (ObjectStorageException $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user