forked from leftypol/leftypol
MediaHandlerTrait.php: add
This commit is contained in:
parent
60119ddbe4
commit
130d250b7b
1 changed files with 19 additions and 0 deletions
19
inc/Service/Media/MediaHandlerTrait.php
Normal file
19
inc/Service/Media/MediaHandlerTrait.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
namespace Vichan\Service\Media;
|
||||||
|
|
||||||
|
use Vichan\Functions\Fs;
|
||||||
|
|
||||||
|
|
||||||
|
trait MediaHandlerTrait {
|
||||||
|
private function move_or_link_or_copy(int $file_kind, string $from, string $to) {
|
||||||
|
if ($file_kind === MediaHandler::FILE_KIND_UPLOADED) {
|
||||||
|
if (!Fs\move_or_copy_uploaded($from, $to)) {
|
||||||
|
throw new MediaException("Could not move or copy uploaded file '$from' to '$to'", MediaException::ERR_IO_ERR);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!Fs\link_or_copy($from, $to)) {
|
||||||
|
throw new MediaException("Could not link or copy '$from' to '$to'", MediaException::ERR_IO_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue