Skip to content

FileHelper

App\Helpers\FileHelper

Get Storage Config Info by File Type

php
FileHelper::fresnsFileStorageConfigByType($type);
Parameter NameTypeRequiredDescription
typeNumberrequiredFile Type Number
Return Example
json
{
    "service": "", // plugin fskey
    "secretId": "",
    "secretKey": "",
    "bucketName": "",
    "bucketRegion": "",
    "bucketEndpoint": "",
    "filesystemDisk": "",
    "accessDomain": "",
    "temporaryUrlStatus": "",
    "temporaryUrlKey": "",
    "temporaryUrlExpiration": "",
    "storageConfigStatus": true, // true means that the storage is fully configured
}

Get File Storage Path

php
FileHelper::fresnsFileStoragePath($fileType, $usageType);
Parameter NameTypeRequiredDescription
fileTypeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
usageTypeNumberrequiredType of File Usage

Get Supported File Formats

php
FileHelper::fresnsFileAcceptByType($type);
Parameter NameTypeRequiredDescription
typeNumberoptional1.Image / 2.Video / 3.Audio / 4.Document
  • Mime format, multiple values separated by commas
  • If type is not passed, output all

Get Single Information by File ID or FID

php
FileHelper::fresnsFileInfoById($fileIdOrFid);
Parameter NameTypeRequiredDescription
fileIdOrFidStringrequiredfiles->id or files->fid
  • The output result will check the anti-leech configuration, and if enabled, output the anti-leech file information.
  • File Information Structure

Get Multiple Information by File ID or FID

php
FileHelper::fresnsFileInfoListByIds($fileIdsOrFids);
Parameter NameTypeRequiredDescription
fileIdsOrFidsArrayrequiredfiles->id or files->fid
  • The output result will check the anti-leech configuration, and if enabled, output the anti-leech file information.
Example
json
{
    "images": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "videos": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "audios": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "documents": [
        {
            // Common Data Structure -> File Info
        }
    ],
}

Get File Information List by Table Field

php
FileHelper::fresnsFileInfoListByTableColumn($tableName, $tableColumn, $tableId, $tableKey);
Parameter NameTypeRequiredDescription
tableNameStringrequiredTable Name
tableColumnStringrequiredTable Column Name
tableIdNumberoptionalPrimary ID
tableKeyStringoptionalPrimary Key Name
  • Either tableId or tableKey must be passed as a parameter
  • The output result will check the anti-leech configuration, and if enabled, output the anti-leech file information.
Example
json
{
    "images": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "videos": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "audios": [
        {
            // Common Data Structure -> File Info
        }
    ],
    "documents": [
        {
            // Common Data Structure -> File Info
        }
    ],
}

Get File URL by File Field

php
FileHelper::fresnsFileUrlByTableColumn($idColumn, $urlColumn, $urlType);
Parameter NameTypeRequiredDescription
idColumnNumberrequiredfile_id field, e.g. users->decorate_file_id
urlColumnStringrequiredfile_url field, e.g. users->decorate_file_url
urlTypeStringoptionalURL type, if not provided, the default imageConfigUrl will be used
urlType
  • imageConfigUrl
  • imageRatioUrl
  • imageSquareUrl
  • imageBigUrl
  • videoPosterUrl
  • videoUrl
  • audioUrl
  • documentPreviewUrl

Get Original URL by File ID or FID

php
FileHelper::fresnsFileOriginalUrlById($fileIdOrFid);
Parameter NameTypeRequiredDescription
fileIdOrFidStringrequiredfiles->id or files->fid
  • The output result will check the anti-leech configuration, and if enabled, output the anti-leech file information.

Released under the Apache-2.0 License