22
33namespace App \Http \Controllers \Api \Assets ;
44
5+ use GuzzleHttp \Client ;
6+ use Illuminate \Support \Str ;
7+ use Illuminate \Http \Request ;
58use App \Entities \Assets \Asset ;
9+ use Dingo \Api \Routing \Helpers ;
610use App \Events \AssetWasCreated ;
7- use App \Exceptions \BodyTooLargeException ;
811use App \Http \Controllers \Controller ;
12+ use Illuminate \Support \Facades \Storage ;
13+ use App \Exceptions \BodyTooLargeException ;
14+ use GuzzleHttp \Exception \TransferException ;
915use App \Transformers \Assets \AssetTransformer ;
1016use Dingo \Api \Exception \StoreResourceFailedException ;
11- use Dingo \Api \Routing \Helpers ;
12- use GuzzleHttp \Client ;
13- use GuzzleHttp \Exception \TransferException ;
14- use Illuminate \Http \Request ;
15- use Illuminate \Support \Facades \Storage ;
16- use Illuminate \Support \Str ;
1717
1818/**
1919 * Class UploadFileController.
@@ -82,7 +82,7 @@ public function store(Request $request)
8282 'user ' => $ request ->user (),
8383 ]);
8484 } else {
85- $ body = ! (base64_decode ($ request ->getContent ())) ? $ request ->getContent () : base64_decode ($ request ->getContent ());
85+ $ body = !(base64_decode ($ request ->getContent ())) ? $ request ->getContent () : base64_decode ($ request ->getContent ());
8686 $ asset = $ this ->uploadFromDirectFile ([
8787 'mime ' => $ request ->header ('Content-Type ' ),
8888 'content ' => $ body ,
@@ -135,7 +135,7 @@ protected function storeInDatabase(array $attributes, $path)
135135 'type ' => $ this ->validMimes [$ attributes ['mime ' ]]['type ' ],
136136 'path ' => $ path ,
137137 'mime ' => $ attributes ['mime ' ],
138- 'user_id ' => ! empty ($ attributes ['user ' ]) ? $ attributes ['user ' ]->id : null ,
138+ 'user_id ' => !empty ($ attributes ['user ' ]) ? $ attributes ['user ' ]->id : null ,
139139 ]);
140140
141141 return $ file ;
@@ -147,7 +147,7 @@ protected function storeInDatabase(array $attributes, $path)
147147 */
148148 protected function storeInFileSystem (array $ attributes )
149149 {
150- $ path = md5 (Str::random (16 ). date ('U ' )). '. ' . $ this ->validMimes [$ attributes ['mime ' ]]['extension ' ];
150+ $ path = md5 (Str::random (16 ) . date ('U ' )) . '. ' . $ this ->validMimes [$ attributes ['mime ' ]]['extension ' ];
151151 Storage::put ($ path , $ attributes ['content ' ]);
152152
153153 return $ path ;
@@ -170,7 +170,7 @@ protected function callFileUrl($url)
170170 return $ response ;
171171 } catch (TransferException $ e ) {
172172 throw new StoreResourceFailedException ('Validation Error ' , [
173- 'url ' => 'The url seems to be unreachable: ' . $ e ->getCode (),
173+ 'url ' => 'The url seems to be unreachable: ' . $ e ->getCode (),
174174 ]);
175175 }
176176 }
@@ -180,7 +180,7 @@ protected function callFileUrl($url)
180180 */
181181 protected function validateMime ($ mime )
182182 {
183- if (! array_key_exists ($ mime , $ this ->validMimes )) {
183+ if (!array_key_exists ($ mime , $ this ->validMimes )) {
184184 throw new StoreResourceFailedException ('Validation Error ' , [
185185 'Content-Type ' => 'The Content Type sent is not valid ' ,
186186 ]);
0 commit comments