Skip to content

Commit

Permalink
Merge pull request #477 from AcclaroInc/bug/using-custom-volume-if-an…
Browse files Browse the repository at this point in the history
…y-selected-to-upload-assets

fixed: an issue where uploaded assets saving to temp directory only
  • Loading branch information
bhupeshappfoster authored Sep 28, 2023
2 parents 551aeb0 + 6dfdcc0 commit af650e1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/controllers/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ public function actionImportFile()

$fileInfo = pathinfo($filename);

$folder = Craft::$app->getAssets()->getUserTemporaryUploadFolder();
$uploadVolumeId = ArrayHelper::getValue(Translations::getInstance()->getSettings(), 'uploadVolume');
$folder = $this->getFolderByVolumeId($uploadVolumeId);

$pathInfo = pathinfo($file);

Expand Down Expand Up @@ -311,7 +312,8 @@ public function actionImportFile()
} else {
$filename = Assets::prepareAssetName($file->name);

$folder = Craft::$app->getAssets()->getUserTemporaryUploadFolder();
$uploadVolumeId = ArrayHelper::getValue(Translations::getInstance()->getSettings(), 'uploadVolume');
$folder = $this->getFolderByVolumeId($uploadVolumeId);

$compatibleFilename = $file->tempName . '.' . Constants::FILE_FORMAT_TXT;

Expand Down Expand Up @@ -576,4 +578,12 @@ private function getZipName($order) {

return $zip_name;
}

private function getFolderByVolumeId($volumeId) {
if ($volumeId == 0) {
return Craft::$app->getAssets()->getUserTemporaryUploadFolder();
} else {
return Craft::$app->getAssets()->getRootFolderByVolumeId($volumeId);
}
}
}

0 comments on commit af650e1

Please sign in to comment.