Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading to directory with correct permissions #3225

Open
wants to merge 5 commits into
base: 15.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
create directory with correct permissions
  • Loading branch information
malyMiso committed Jun 17, 2024
commit cd3528c8e42ceb8f81d6c8fc7e8c963c33aa0357
10 changes: 9 additions & 1 deletion packages/framework/src/Component/FileUpload/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace Shopsys\FrameworkBundle\Component\FileUpload;

use League\Flysystem\Config;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use League\Flysystem\MountManager;
use League\Flysystem\StorageAttributes;
use League\Flysystem\Visibility;
use Shopsys\FrameworkBundle\Component\FileUpload\Exception\MoveToEntityFailedException;
use Shopsys\FrameworkBundle\Component\FileUpload\Exception\UploadFailedException;
use Shopsys\FrameworkBundle\Component\String\TransformString;
Expand Down Expand Up @@ -130,9 +132,15 @@ public function getTemporaryDirectory()
*/
public function getUploadDirectory($isImage, $category, $targetDirectory)
{
return ($isImage ? $this->imageDir : $this->uploadedFileDir)
$uploadDirectory = ($isImage ? $this->imageDir : $this->uploadedFileDir)
. $category
. ($targetDirectory !== null ? '/' . $targetDirectory : '');

if ($this->filesystem->directoryExists($uploadDirectory) === false) {
$this->filesystem->createDirectory($uploadDirectory, [Config::OPTION_VISIBILITY => Visibility::PUBLIC]);
}

return $uploadDirectory;
}

/**
Expand Down
Loading