Throw exception when filename cannot be found
This commit is contained in:
parent
f70bd6b032
commit
0b5edee585
|
@ -6,6 +6,7 @@ use Event;
|
|||
use Generator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Media\Classes\MediaLibrary;
|
||||
use Zoomyboy\Social\Exceptions\SocialException;
|
||||
use Zoomyboy\Social\Models\Page;
|
||||
use Zoomyboy\Social\Models\Setting;
|
||||
|
||||
|
@ -67,6 +68,11 @@ abstract class SocialService {
|
|||
public function saveUrl(string $source, ?string $filename = null): string
|
||||
{
|
||||
$filename = $filename ?: pathinfo(parse_url($source, PHP_URL_PATH), PATHINFO_BASENAME);
|
||||
|
||||
if (!pathinfo($filename, PATHINFO_FILENAME)) {
|
||||
throw new SocialException('No real filename for storage given in "'.$source.'"');
|
||||
}
|
||||
|
||||
$file = $this->page->mediaPath.$filename;
|
||||
|
||||
if (!$this->media->exists($file)) {
|
||||
|
|
|
@ -8,5 +8,10 @@
|
|||
"name": "Philipp Lang",
|
||||
"email": "philipp.lang@dpsg-koeln.de"
|
||||
}
|
||||
]
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Aweos\\Social\\Exceptions\\": "./exceptions"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Zoomyboy\Social\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class SocialException extends Exception {
|
||||
|
||||
}
|
Loading…
Reference in New Issue