Exemplo n.º 1
5
 /**
  * @param AssetInterface $asset
  * @param UploadedFile   $file
  *
  * @return AssetVersion
  */
 public function createVersionFromFile(AssetInterface $asset, UploadedFile $file)
 {
     list($width, $height) = getimagesize($file->getRealPath());
     $extension = File::extension($file->getClientOriginalName(), $file->getMimetype());
     $version = $this->version->create(['asset_id' => $asset->getId(), 'extension' => $extension, 'filesize' => $file->getClientSize(), 'filename' => $file->getClientOriginalName(), 'width' => $width, 'height' => $height, 'edited_at' => time(), 'edited_by' => Auth::getPerson()->getId(), 'mimetype' => $file->getMimeType(), 'metadata' => File::exif($file->getRealPath())]);
     $file->move($asset->directory(), $version->id);
     return $version;
 }
Exemplo n.º 2
0
 public function testExtensionFromMimetype()
 {
     $config = (include __DIR__ . '/../../src/config/boomcms/assets.php');
     $extensions = $config['assets']['extensions'];
     foreach ($extensions as $extension => $mimetype) {
         $this->assertEquals($extension, File::extensionFromMimetype($mimetype));
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $versions = AssetVersion::whereNull('extension')->get();
     foreach ($versions as $v) {
         $v->extension = File::extensionFromMimetype($v->mimetype);
         $v->save();
     }
 }