Skip to content

Commit

Permalink
Update ProjectFolderUpload.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bastihilger committed Aug 4, 2022
1 parent d600c9d commit c16ecb0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Services/ProjectFolderUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@ protected function importFile($artist, $slideshow, $file, $filename)
$newFilename = str_replace('-', '_', $artist->slug).'_'.$newFilename;
}

$mediaItem = MediaModel::where('original_name', $filename)->first();
$mediaItem = MediaModel::where('original_name', $newFilename)->first();

if (! $mediaItem) {
try {

$tmpPath = Storage::putFileAs('tmp-uploads', $file, $filename);
Log::error($tmpPath);
Log::error(config('filesystems.disks.local.root').'/'.$tmpPath);
// $mediaItem = API::upload(storage_path('app/'.$tmpPath), null, $newFilename);
// $response['status'] = 'success';
// $response['reason'] = '';
} catch (Exception $e) {
Log::error($e);
$tmpDir = base_path('storage/tmp');
if (!is_dir($tmpDir)) {
mkdir($tmpDir);
}

$tmpPath = $tmpDir.'/'.$newFilename;
move_uploaded_file($file, $tmpPath);

$mediaItem = API::upload($tmpPath, null, $newFilename);
$response['status'] = 'success';
$response['reason'] = '';
} else {
$response['reason'] = 'already exists';
}
Expand Down

0 comments on commit c16ecb0

Please sign in to comment.