MetaFox

FileType
in package
implements MetaFoxFileTypeInterface

Table of Contents

Interfaces

MetaFoxFileTypeInterface

Constants

AUDIO_MIME_TYPE_REGEX  = '/^audio\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
AUDIO_MIMES_TYPES  = 'audio/mp3'
PHOTO_MIME_TYPE_REGEX  = '/^image\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
PHOTO_MIMES_TYPES  = 'image/jpg,image/jpeg,image/png,image/gif,image/bmp,image/webp'
VIDEO_MIME_TYPE_REGEX  = '/^video\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
VIDEO_MIMES_TYPES  = 'video/*'

Properties

$types  : array<string|int, string>

Methods

getAllowableTypes()  : array<string|int, string>
getFilesizeInMegabytes()  : float
getFilesizePerType()  : int
This method return how many bytes should a type can be uploaded to server.
getFilesizeReadableString()  : string
getMimeTypeFromType()  : string
getTypeByMime()  : string|null
isAllowType()  : bool
transformFileType()  : string
verifyMime()  : bool
verifyMimeTypeByType()  : bool
verifyAudioMimeType()  : bool
verifyImageMimeType()  : bool
verifyVideoMimeType()  : bool

Constants

AUDIO_MIME_TYPE_REGEX

public mixed AUDIO_MIME_TYPE_REGEX = '/^audio\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'

AUDIO_MIMES_TYPES

public mixed AUDIO_MIMES_TYPES = 'audio/mp3'

PHOTO_MIME_TYPE_REGEX

public mixed PHOTO_MIME_TYPE_REGEX = '/^image\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'

PHOTO_MIMES_TYPES

public mixed PHOTO_MIMES_TYPES = 'image/jpg,image/jpeg,image/png,image/gif,image/bmp,image/webp'

VIDEO_MIME_TYPE_REGEX

public mixed VIDEO_MIME_TYPE_REGEX = '/^video\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'

VIDEO_MIMES_TYPES

public mixed VIDEO_MIMES_TYPES = 'video/*'

Properties

$types

public static array<string|int, string> $types = [\MetaFox\Platform\MetaFoxFileType::PHOTO_TYPE => self::PHOTO_MIMES_TYPES, \MetaFox\Platform\MetaFoxFileType::VIDEO_TYPE => self::VIDEO_MIMES_TYPES, \MetaFox\Platform\MetaFoxFileType::AUDIO_TYPE => self::AUDIO_MIMES_TYPES]

Methods

getAllowableTypes()

public getAllowableTypes(string $type[, bool $useConverter = true ]) : array<string|int, string>
Parameters
$type : string
$useConverter : bool = true
Tags
inheritDoc

TODO: Can be extend later to add more mime type

Return values
array<string|int, string>

getFilesizeInMegabytes()

public getFilesizeInMegabytes(string $type) : float
Parameters
$type : string
Return values
float

getFilesizePerType()

This method return how many bytes should a type can be uploaded to server.

public getFilesizePerType(string $type) : int
Parameters
$type : string
Tags
inheritDoc
Return values
int

getFilesizeReadableString()

public getFilesizeReadableString(int $bytes) : string
Parameters
$bytes : int
Tags
inheritDoc
Return values
string

getMimeTypeFromType()

public getMimeTypeFromType(string $type[, bool $useConverter = true ]) : string
Parameters
$type : string
$useConverter : bool = true
Tags
inheritDoc
Return values
string

getTypeByMime()

public getTypeByMime(string|null $mimeType) : string|null
Parameters
$mimeType : string|null
Tags
inheritDoc
Return values
string|null

isAllowType()

public isAllowType(string $type) : bool
Parameters
$type : string
Return values
bool

transformFileType()

public transformFileType(string $fileType) : string
Parameters
$fileType : string
Return values
string

verifyMime()

public verifyMime(UploadedFile $file, string $type) : bool
Parameters
$file : UploadedFile
$type : string
Return values
bool

verifyMimeTypeByType()

public verifyMimeTypeByType(string|null $mimeType[, string $fileType = 'photo' ]) : bool
Parameters
$mimeType : string|null
$fileType : string = 'photo'
Return values
bool

verifyAudioMimeType()

protected verifyAudioMimeType(string $mimeType) : bool
Parameters
$mimeType : string
Return values
bool

verifyImageMimeType()

protected verifyImageMimeType(string $mimeType) : bool
Parameters
$mimeType : string
Return values
bool

verifyVideoMimeType()

protected verifyVideoMimeType(string $mimeType) : bool
Parameters
$mimeType : string
Return values
bool

        
On this page

Search results