getFilesize() public method

Get the size of the image data in bytes
public getFilesize ( ) : integer
return integer
Esempio n. 1
0
 /**
  * @covers Imbo\Model\Image::setBlob
  * @covers Imbo\Model\Image::getBlob
  * @covers Imbo\Model\Image::getFilesize
  * @covers Imbo\Model\Image::setFilesize
  * @covers Imbo\Model\Image::getChecksum
  * @covers Imbo\Model\Image::setChecksum
  */
 public function testCanSetAndGetBlob()
 {
     $blob = 'some string';
     $hash = md5($blob);
     $this->assertSame($this->image, $this->image->setBlob($blob));
     $this->assertSame($blob, $this->image->getBlob());
     $this->assertSame(11, $this->image->getFilesize());
     $this->assertSame($hash, $this->image->getChecksum());
     $blob = 'some other string';
     $hash = md5($blob);
     $this->assertSame($this->image, $this->image->setBlob($blob));
     $this->assertSame($blob, $this->image->getBlob());
     $this->assertSame(17, $this->image->getFilesize());
     $this->assertSame($hash, $this->image->getChecksum());
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function insertImage($publicKey, $imageIdentifier, Image $image)
 {
     $now = time();
     if ($added = $image->getAddedDate()) {
         $added = $added->getTimestamp();
     }
     if ($updated = $image->getUpdatedDate()) {
         $updated = $updated->getTimestamp();
     }
     if ($id = $this->getImageId($publicKey, $imageIdentifier)) {
         return (bool) $this->getConnection()->update($this->tableNames['imageinfo'], array('updated' => $now), array('id' => $id));
     }
     return (bool) $this->getConnection()->insert($this->tableNames['imageinfo'], array('size' => $image->getFilesize(), 'publicKey' => $publicKey, 'imageIdentifier' => $imageIdentifier, 'extension' => $image->getExtension(), 'mime' => $image->getMimeType(), 'added' => $added ?: $now, 'updated' => $updated ?: $now, 'width' => $image->getWidth(), 'height' => $image->getHeight(), 'checksum' => $image->getChecksum(), 'originalChecksum' => $image->getOriginalChecksum()));
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function insertImage($publicKey, $imageIdentifier, Image $image)
 {
     $now = time();
     if ($added = $image->getAddedDate()) {
         $added = $added->getTimestamp();
     }
     if ($updated = $image->getUpdatedDate()) {
         $updated = $updated->getTimestamp();
     }
     if ($this->imageExists($publicKey, $imageIdentifier)) {
         try {
             $this->getImageCollection()->update(['publicKey' => $publicKey, 'imageIdentifier' => $imageIdentifier], ['$set' => ['updated' => $now]], ['multiple' => false]);
             return true;
         } catch (MongoException $e) {
             throw new DatabaseException('Unable to save image data', 500, $e);
         }
     }
     $data = ['size' => $image->getFilesize(), 'publicKey' => $publicKey, 'imageIdentifier' => $imageIdentifier, 'extension' => $image->getExtension(), 'mime' => $image->getMimeType(), 'metadata' => [], 'added' => $added ?: $now, 'updated' => $updated ?: $now, 'width' => $image->getWidth(), 'height' => $image->getHeight(), 'checksum' => $image->getChecksum(), 'originalChecksum' => $image->getOriginalChecksum()];
     try {
         $this->getImageCollection()->insert($data);
     } catch (MongoException $e) {
         throw new DatabaseException('Unable to save image data', 500, $e);
     }
     return true;
 }