Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #24 from ipunkt/analysis-XVNWVO
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
Robert Kummer authored Jan 24, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9481d34 + 7716911 commit a02522e
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions app/Jobs/CreateLocalFile.php
Original file line number Diff line number Diff line change
@@ -9,63 +9,63 @@

class CreateLocalFile
{
use Dispatchable;
use Dispatchable;

/**
* @var \Illuminate\Http\UploadedFile
*/
private $file;
/**
* @var \Illuminate\Http\UploadedFile
*/
private $file;

/**
* @var string
*/
private $reference;
/**
* @var string
*/
private $reference;

public function __construct(string $reference, UploadedFile $file)
{
$this->reference = $reference;
$this->file = $file;
}
public function __construct(string $reference, UploadedFile $file)
{
$this->reference = $reference;
$this->file = $file;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$fileHandle = $this->file->openFile();
$content = $fileHandle->fread($this->file->getSize());
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$fileHandle = $this->file->openFile();
$content = $fileHandle->fread($this->file->getSize());

$proxyFile = new ProxyFile([
'reference' => $this->reference,
'type' => 'local',
'filename' => $this->file->getClientOriginalName(),
'mimetype' => $this->file->getClientMimeType(),
'size' => $this->file->getSize(),
'checksum' => sha1($content),
]);
$proxyFile->save();
$proxyFile = new ProxyFile([
'reference' => $this->reference,
'type' => 'local',
'filename' => $this->file->getClientOriginalName(),
'mimetype' => $this->file->getClientMimeType(),
'size' => $this->file->getSize(),
'checksum' => sha1($content),
]);
$proxyFile->save();

/** @var \App\LocalFile $localFile */
$localFile = $proxyFile->localFile()->create([
'path' => uniqid('', true),
]);
/** @var \App\LocalFile $localFile */
$localFile = $proxyFile->localFile()->create([
'path' => uniqid('', true),
]);

/** @var Filesystem|\Illuminate\Filesystem\FilesystemAdapter $filesystem */
$filesystem = app(Filesystem::class);
/** @var Filesystem|\Illuminate\Filesystem\FilesystemAdapter $filesystem */
$filesystem = app(Filesystem::class);

if (!$filesystem->exists('local')) {
$filesystem->makeDirectory('local');
}
if (! $filesystem->exists('local')) {
$filesystem->makeDirectory('local');
}

$path = $localFile->getLocalStoragePath();
$path = $localFile->getLocalStoragePath();

$fh = fopen($this->file->getRealPath(), 'rb');
if ($filesystem->put($path, $fh)) {
$localFile->path = $path;
$localFile->save();
}
fclose($fh);
}
$fh = fopen($this->file->getRealPath(), 'rb');
if ($filesystem->put($path, $fh)) {
$localFile->path = $path;
$localFile->save();
}
fclose($fh);
}
}

0 comments on commit a02522e

Please sign in to comment.