diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index 5455f03..ffeb2b6 100644 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -457,20 +457,10 @@ class FileController extends Controller else { // create a new path $path = pathinfo($file->stored_at, PATHINFO_BASENAME); - // if file has been uploaded to S3, - if ($file->s3 == 1) { - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $s3file); - } else { - // modify path - $path = 'public/' . $path; - // get local file - $localFile = Storage::disk('local')->get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $localFile); - } + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($path, $s3file); // define download path as being the file on the public drive $downloadURL = asset(Storage::disk('public')->url($path)); // define filename @@ -538,20 +528,10 @@ class FileController extends Controller else { // create a new path $path = pathinfo($file->stored_at, PATHINFO_BASENAME); - // if file has been uploaded to S3, - if ($file->s3 == 1) { - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $s3file); - } else { - // modify path - $path = 'public/' . $path; - // get local file - $localFile = Storage::disk('local')->get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $localFile); - } + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($path, $s3file); // define download path as being the file on the public drive $downloadURL = asset(Storage::disk('public')->url($path)); // define filename @@ -608,22 +588,12 @@ class FileController extends Controller } // otherwise else { - // create a new path off + // create a new path $path = pathinfo($file->stored_at, PATHINFO_BASENAME); - // if file has been uploaded to S3, - if ($file->s3 == 1) { - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $s3file); - } else { - // modify path - $path = 'public/' . $path; - // get local file - $localFile = Storage::disk('local')->get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $localFile); - } + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($path, $s3file); // define download path as being the file on the public drive $downloadURL = asset(Storage::disk('public')->url($path)); // define filename @@ -692,20 +662,10 @@ class FileController extends Controller else { // create a new path $path = pathinfo($file->stored_at, PATHINFO_BASENAME); - // if file has been uploaded to S3, - if ($file->s3 == 1) { - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $s3file); - } else { - // modify path - $path = 'public/' . $path; - // get local file - $localFile = Storage::disk('local')->get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $localFile); - } + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($path, $s3file); // define download path as being the file on the public drive $downloadURL = asset(Storage::disk('public')->url($path)); // define filename @@ -762,22 +722,12 @@ class FileController extends Controller } // otherwise else { - // create a new path off "public/" + // create a new path $path = pathinfo($file->stored_at, PATHINFO_BASENAME); - // if file has been uploaded to S3, - if ($file->s3 == 1) { - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $s3file); - } else { - // modify path - $path = 'public/' . $path; - // get local file - $localFile = Storage::disk('local')->get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($path, $localFile); - } + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($path, $s3file); // define download path as being the file on the public drive $downloadURL = asset(Storage::disk('public')->url($path)); // define filename @@ -1076,20 +1026,14 @@ class FileController extends Controller if ($file->children->isEmpty()) { // set $internalPath to reflect file $internalPath = $parent . $file->name; - // default file path is stored on local storage - $filePath = Storage::disk('local')->path($file->stored_at); - - // if the file is uploaded to S3 - if ($file->s3 == 1) { - // create a new path - $filePath = pathinfo($file->stored_at, PATHINFO_BASENAME); - // pull the file off S3 - $s3file = Storage::get($file->stored_at); - // put it on the public drive for use - Storage::disk('public')->put($filePath, $s3file); - // reassign $filePath to the actual file path - $filePath = Storage::disk('public')->path($filePath); - } + // create a new path + $filePath = pathinfo($file->stored_at, PATHINFO_BASENAME); + // pull the file off S3 + $s3file = Storage::disk('s3')->get($file->stored_at); + // put it on the public drive for use + Storage::disk('public')->put($filePath, $s3file); + // reassign $filePath to the actual file path + $filePath = Storage::disk('public')->path($filePath); // add file to archive $archive->addFile($filePath, $internalPath);