77use CodingSocks \UploadHandler \Exception \InternalServerErrorHttpException ;
88use CodingSocks \UploadHandler \StorageConfig ;
99use Illuminate \Http \Request ;
10- use Illuminate \Http \UploadedFile ;
11- use Illuminate \Support \Facades \Storage ;
12- use Symfony \Component \HttpFoundation \BinaryFileResponse ;
1310use Symfony \Component \HttpFoundation \Response ;
14- use Symfony \Component \HttpFoundation \ResponseHeaderBag ;
1511use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
16- use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1712
1813abstract class BaseHandler
1914{
@@ -28,27 +23,6 @@ abstract class BaseHandler
2823 */
2924 abstract public function handle (Request $ request , StorageConfig $ config , Closure $ fileUploaded = null ): Response ;
3025
31- /**
32- * @param string $filename
33- * @param \CodingSocks\UploadHandler\StorageConfig $storageConfig
34- *
35- * @return \Symfony\Component\HttpFoundation\Response
36- */
37- public function fileResponse (string $ filename , StorageConfig $ storageConfig ): Response
38- {
39- /** @var \Illuminate\Filesystem\FilesystemAdapter $disk */
40- $ disk = Storage::disk ($ storageConfig ->getDisk ());
41- $ prefix = $ storageConfig ->getMergedDirectory () . '/ ' ;
42-
43- if (! $ disk ->exists ($ prefix . $ filename )) {
44- throw new NotFoundHttpException ($ filename . ' file not found on server ' );
45- }
46-
47- $ path = $ disk ->path ($ prefix . $ filename );
48-
49- return new BinaryFileResponse ($ path , 200 , [], true , ResponseHeaderBag::DISPOSITION_ATTACHMENT );
50- }
51-
5226 /**
5327 * Check if the request type of the given request is in the specified list.
5428 *
0 commit comments