summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-04 18:26:35 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-04 18:26:35 -0500
commit40cd74aa9507c37b5cff6d1307a64894e966892e (patch)
tree80a8e96e73eb91a2922deb5142d4b8b33a032372 /app/Model
parent630707050755f414ce91faf880fd407a6fe63174 (diff)
Make base64 decoding optional for uploaded data
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/FileModel.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/app/Model/FileModel.php b/app/Model/FileModel.php
index b5852b08..d04b03bf 100644
--- a/app/Model/FileModel.php
+++ b/app/Model/FileModel.php
@@ -307,31 +307,35 @@ abstract class FileModel extends Base
* Handle file upload (base64 encoded content)
*
* @access public
- * @param integer $id
- * @param string $original_filename
- * @param string $blob
- * @return bool|integer
+ * @param integer $id
+ * @param string $originalFilename
+ * @param string $data
+ * @param bool $isEncoded
+ * @return bool|int
*/
- public function uploadContent($id, $original_filename, $blob)
+ public function uploadContent($id, $originalFilename, $data, $isEncoded = true)
{
try {
- $data = base64_decode($blob);
+ if ($isEncoded) {
+ $data = base64_decode($data);
+ }
if (empty($data)) {
+ $this->logger->error(__METHOD__.': Content upload with no data');
return false;
}
- $destination_filename = $this->generatePath($id, $original_filename);
- $this->objectStorage->put($destination_filename, $data);
+ $destinationFilename = $this->generatePath($id, $originalFilename);
+ $this->objectStorage->put($destinationFilename, $data);
- if ($this->isImage($original_filename)) {
- $this->generateThumbnailFromData($destination_filename, $data);
+ if ($this->isImage($originalFilename)) {
+ $this->generateThumbnailFromData($destinationFilename, $data);
}
return $this->create(
$id,
- $original_filename,
- $destination_filename,
+ $originalFilename,
+ $destinationFilename,
strlen($data)
);
} catch (ObjectStorageException $e) {