You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

35 lines
798 B

<?php
namespace CustomHandlers\Actions;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Mimey\MimeTypes;
/**
*
*
*
*/
class FileDownload extends ActionHandler
{
public function run()
{
if (isset($this->data->enclosure) && isset($this->data->enclosure->attributes()->url)) {
// get mimes
$mimes = new MimeTypes();
$extension = $mimes->getExtension($this->data->enclosure->attributes()->type);
// if extension valid
if ($extension) {
$filename = Str::slug($this->data->title).'.'.$extension;
Storage::download($this->data->enclosure->attributes()->url)->put($filename);
} else {
// @TODO what you do
}
}
}
}