getSize() public method

public getSize ( ) : integer
return integer size of the file
 /**
  * Returns the size of the file
  *
  * !! WARNING !!
  * Calling this loads the entire file into memory,
  * unless it is on a stream-capable filesystem.
  * In case of bigger files this could throw exceptions,
  * and will have heavy performance footprint.
  * !! ------- !!
  *
  */
 public function getSize()
 {
     // This can only work on streamable files, so basically local files,
     // still only perform it once even on local files to avoid bothering the filesystem.php g
     if ($this->filesystem->getAdapter() instanceof StreamFactory && !$this->size) {
         if ($this->streamWrapperPrefix) {
             try {
                 $this->setSize(filesize($this->streamWrapperPrefix . $this->getKey()));
             } catch (\Exception $e) {
                 // Fail gracefully if there was a problem with opening the file and
                 // let gaufrette load the file into memory allowing it to throw exceptions
                 // if that doesn't work either.
                 // Not empty to make the scrutiziner happy.
                 return parent::getSize();
             }
         }
     }
     return parent::getSize();
 }
Beispiel #2
0
 public function getContentLength()
 {
     return $this->file->getSize();
 }
 /**
  * Return the upload status.
  *
  * @param  \SRIO\RestUploadBundle\Upload\UploadContext $context
  * @param  ResumableUploadSession                      $uploadSession
  * @param  \Gaufrette\File                             $file
  * @param  array                                       $range
  * @return UploadResult
  */
 protected function requestUploadStatus(UploadContext $context, ResumableUploadSession $uploadSession, File $file, array $range)
 {
     if (!$file->exists()) {
         $length = 0;
     } else {
         $length = $file->getSize();
     }
     $response = new Response(null, $length == $range['total'] ? 201 : 308);
     if ($length < 1) {
         $length = 1;
     }
     $response->headers->set('Range', '0-' . ($length - 1));
     $result = new UploadResult();
     $result->setResponse($response);
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function getSize()
 {
     return $this->file->getSize();
 }