Method | Description | |
---|---|---|
__construct ( FileSystemManager $filesystem, Plank\Mediable\SourceAdapters\SourceAdapterFactory $factory, array | null $config = null ) | Constructor. | |
fromSource ( mixed $source ) : static | Set the source for the file. | |
getOnDuplicateBehavior ( ) : string | Get current behavior when duplicate file is uploaded. | |
import ( string $disk, string $directory, string $filename, string $extension ) : |
Create a Media record for a file already on a disk. | |
importPath ( string $disk, string $path ) : |
Create a Media record for a file already on a disk. | |
inferAggregateType ( string $mime_type, string $extension ) : string | Determine the aggregate type of the file based on the MIME type and the extension. | |
onDuplicateError ( ) : static | Throw an exception when file already exists at the destination. | |
onDuplicateIncrement ( ) : static | Append incremented counter to file name when file already exists at destination. | |
onDuplicateReplace ( ) : static | Overwrite existing file when file already exists at destination. | |
possibleAggregateTypesForExtension ( string $extension ) : string | null | Determine the aggregate type of the file based on the extension. | |
possibleAggregateTypesForMimeType ( string $mime ) : string | Determine the aggregate type of the file based on the MIME type. | |
setAllowUnrecognizedTypes ( boolean $allow ) : static | Change whether files not matching any aggregate types are allowed. | |
setAllowedAggregateTypes ( array $allowed_types ) : static | Set a list of aggregate types that the source file must be restricted to. | |
setAllowedExtensions ( array $allowed_extensions ) : static | Set a list of file extensions that the source file must be restricted to. | |
setAllowedMimeTypes ( array $allowed_mimes ) : static | Set a list of MIME types that the source file must be restricted to. | |
setMaximumSize ( integer $size ) : static | Change the maximum allowed filesize. | |
setModelClass ( string $class ) : static | Change the class to use for generated Media. | |
setOnDuplicateBehavior ( string $behavior ) : static | Change the behaviour for when a file already exists at the destination. | |
setStrictTypeChecking ( boolean $strict ) : static | Change whether both the MIME type and extensions must match the same aggregate type. | |
setTypeDefinition ( string $type, array $mime_types, array $extensions ) : static | Add or update the definition of a aggregate type. | |
toDestination ( string $disk, string $directory ) : static | Set the filesystem disk and relative directory where the file will be saved. | |
toDirectory ( string $directory ) : static | Set the directory relative to the filesystem disk at which the file will be saved. | |
toDisk ( string $disk ) : static | Set the filesystem disk on which the file will be saved. | |
update ( |
Reanalyze a media record's file and adjust the aggregate type and size, if necessary. | |
upload ( ) : |
Process the file upload. | |
useFilename ( string $filename ) : static | Specify the filename to copy to the file to. | |
useHashForFilename ( ) : static | Indicates to the uploader to generate a filename using the file's MD5 hash. | |
useOriginalFilename ( ) : static | Restore the default behaviour of using the source file's filename. |
Method | Description | |
---|---|---|
deleteExistingMedia ( |
Delete the media that previously existed at a destination. | |
generateFilename ( ) : string | Generate the model's filename. | |
generateHash ( ) : string | Calculate hash of source contents. | |
generateUniqueFilename ( |
Increment model's filename until one is found that doesn't already exist. | |
handleDuplicate ( |
Decide what to do about duplicated files. | |
makeModel ( ) : |
Generate an instance of the Media class. | |
sanitizeFileName ( string $file ) : string | Remove any disallowed characters from a filename. | |
sanitizePath ( string $path ) : string | Remove any disallowed characters from a directory value. | |
verifyDestination ( |
Verify that the intended destination is available and handle any duplications. | |
verifyDisk ( string $disk ) : string | Ensure that the provided filesystem disk name exists and is allowed. | |
verifyExtension ( string $extension ) : string | Ensure that the file's extension is allowed. | |
verifyFileSize ( integer $size ) : integer | Verify that the file being uploaded is not larger than the maximum. | |
verifyMimeType ( string $mime_type ) : string | Ensure that the file's mime type is allowed. | |
verifySource ( ) : void | Ensure that a valid source has been provided. |
public __construct ( FileSystemManager $filesystem, Plank\Mediable\SourceAdapters\SourceAdapterFactory $factory, array | null $config = null ) | ||
$filesystem | FileSystemManager | |
$factory | Plank\Mediable\SourceAdapters\SourceAdapterFactory | |
$config | array | null |
public fromSource ( mixed $source ) : static | ||
$source | mixed | |
return | static |
public getOnDuplicateBehavior ( ) : string | ||
return | string |
public importPath ( string $disk, string $path ) : |
||
$disk | string | |
$path | string | Path to file, relative to disk root |
return |
public onDuplicateError ( ) : static | ||
return | static |
public onDuplicateIncrement ( ) : static | ||
return | static |
public onDuplicateReplace ( ) : static | ||
return | static |
public possibleAggregateTypesForMimeType ( string $mime ) : string | ||
$mime | string | |
return | string |
public setAllowUnrecognizedTypes ( boolean $allow ) : static | ||
$allow | boolean | |
return | static |
public setAllowedAggregateTypes ( array $allowed_types ) : static | ||
$allowed_types | array | |
return | static |
public setAllowedExtensions ( array $allowed_extensions ) : static | ||
$allowed_extensions | array | |
return | static |
public setAllowedMimeTypes ( array $allowed_mimes ) : static | ||
$allowed_mimes | array | |
return | static |
public setMaximumSize ( integer $size ) : static | ||
$size | integer | |
return | static |
public setModelClass ( string $class ) : static | ||
$class | string | |
return | static |
public setOnDuplicateBehavior ( string $behavior ) : static | ||
$behavior | string | |
return | static |
public setStrictTypeChecking ( boolean $strict ) : static | ||
$strict | boolean | |
return | static |
public toDestination ( string $disk, string $directory ) : static | ||
$disk | string | |
$directory | string | |
return | static |
public toDirectory ( string $directory ) : static | ||
$directory | string | |
return | static |
public upload ( ) : |
||
return |
public useFilename ( string $filename ) : static | ||
$filename | string | |
return | static |
public useHashForFilename ( ) : static | ||
return | static |
public useOriginalFilename ( ) : static | ||
return | static |