Store temporary files in storage dir

closes #482
This commit is contained in:
Toby Zerner 2015-10-14 15:49:31 +10:30
parent 0544f5cb30
commit c557bcde28

View File

@ -14,6 +14,7 @@ use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Event\AvatarWillBeSaved; use Flarum\Event\AvatarWillBeSaved;
use Flarum\Core\Repository\UserRepository; use Flarum\Core\Repository\UserRepository;
use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Core\Support\DispatchEventsTrait;
use Flarum\Foundation\Application;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use League\Flysystem\Adapter\Local; use League\Flysystem\Adapter\Local;
@ -37,16 +38,22 @@ class UploadAvatarHandler
*/ */
protected $uploadDir; protected $uploadDir;
/**
* @var Application
*/
protected $app;
/** /**
* @param Dispatcher $events * @param Dispatcher $events
* @param UserRepository $users * @param UserRepository $users
* @param FilesystemInterface $uploadDir * @param FilesystemInterface $uploadDir
*/ */
public function __construct(Dispatcher $events, UserRepository $users, FilesystemInterface $uploadDir) public function __construct(Dispatcher $events, UserRepository $users, FilesystemInterface $uploadDir, Application $app)
{ {
$this->events = $events; $this->events = $events;
$this->users = $users; $this->users = $users;
$this->uploadDir = $uploadDir; $this->uploadDir = $uploadDir;
$this->app = $app;
} }
/** /**
@ -64,7 +71,7 @@ class UploadAvatarHandler
$this->assertCan($actor, 'edit', $user); $this->assertCan($actor, 'edit', $user);
} }
$tmpFile = tempnam(sys_get_temp_dir(), 'avatar'); $tmpFile = tempnam($this->app->storagePath().'/tmp', 'avatar');
$command->file->moveTo($tmpFile); $command->file->moveTo($tmpFile);
$manager = new ImageManager; $manager = new ImageManager;