File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 22
33namespace  EWZ \SymfonyAdminBundle \FileUploader ;
44
5+ use  Aws \S3 \Exception \S3Exception ;
56use  Aws \S3 \S3Client ;
67use  Ramsey \Uuid \Uuid ;
78use  Symfony \Component \HttpFoundation \File \UploadedFile ;
@@ -161,10 +162,14 @@ public function getMimeType(string $fileName): ?string
161162    {
162163        $ fileName$ this cleanFileName ($ fileName
163164
164-         $ result$ this s3Client ->getObject ([
165-             'Bucket '  => $ this s3Bucket ,
166-             'Key '  => $ fileName
167-         ]);
165+         try  {
166+             $ result$ this s3Client ->getObject ([
167+                 'Bucket '  => $ this s3Bucket ,
168+                 'Key '  => $ fileName
169+             ]);
170+         } catch  (S3Exception $ e
171+             return  null ;
172+         }
168173
169174        if  (isset ($ result'NoSuchKey ' ])) {
170175            return  null ;
@@ -180,10 +185,14 @@ public function getFileSize(string $fileName): ?int
180185    {
181186        $ fileName$ this cleanFileName ($ fileName
182187
183-         $ result$ this s3Client ->getObject ([
184-             'Bucket '  => $ this s3Bucket ,
185-             'Key '  => $ fileName
186-         ]);
188+         try  {
189+             $ result$ this s3Client ->getObject ([
190+                 'Bucket '  => $ this s3Bucket ,
191+                 'Key '  => $ fileName
192+             ]);
193+         } catch  (S3Exception $ e
194+             return  null ;
195+         }
187196
188197        if  (isset ($ result'NoSuchKey ' ])) {
189198            return  null ;
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments