Skip to content

Commit

Permalink
Load attributes on upload file save.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliishvakin committed Aug 17, 2017
1 parent f5ce6e9 commit 5e67f6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Api/v1/FilesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function setConfig($config)
$this->config = $config;
}

public function saveUploaded(FileInterface $file)
public function saveUploaded(FileInterface $file, array $attributes = null)
{
$fileExt = $file->getExt();
$tmpPath = $file->getPath();
Expand All @@ -110,6 +110,10 @@ public function saveUploaded(FileInterface $file)
/** @var File $newFile */
$newFile = $this->getOperator()->execute($createCommand);

if (!empty($attributes)) {
$this->getOperator()->load($newFile, $attributes);
}

$newFile->setId($id);
$newFile->setPath($path);
$newFile->setPosition($newFilePatch);
Expand Down Expand Up @@ -149,7 +153,7 @@ public function getNewFilePath($fileExt, UuidComplexInterface $uuid)
{
$firstDirsLevelCount = $this->getConfig([Module::MODULE_ID, "firstDirsLevelCount"], 16);
$secondDirsLevelCount = $this->getConfig([Module::MODULE_ID, "secondDirsLevelCount"], 16);
$dir1 = ($uuid->getId() + (integer) $uuid->getDate()->format("B")) % $firstDirsLevelCount;
$dir1 = ($uuid->getId() + (integer)$uuid->getDate()->format("B")) % $firstDirsLevelCount;
$dir1 = $this->hash($dir1);
$dir2 = $uuid->getId() % $secondDirsLevelCount;
$dir2 = $this->hash($dir2);
Expand Down

0 comments on commit 5e67f6c

Please sign in to comment.