Skip to content

File Command Word

getUploadToken

php
\FresnsCmdWord::plugin('Fresns')->getUploadToken($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
nameStringrequiredThe filename of this upload
expireTimeNumberrequiredExpiration time, in seconds
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        "storageId": "Number / Storage service provider ID, see dictionary key-value",
        "token": "String / SDK upload token requested from the plugin",
        "expireTime": "Number / Expiration time, in seconds" // If not available, output null
    }
}

uploadFile

php
\FresnsCmdWord::plugin('Fresns')->uploadFile($wordBody);
Parameter NameTypeRequiredDescription
platformIdNumberrequiredPlatform number (key value from the configuration table platforms)
usageTypeNumberrequiredFile usage type
tableNameStringrequiredSource table name (which table is using)
tableColumnStringrequiredSource field name (which field is using)
tableIdNumberoptionalSource table primary id
tableKeyStringoptionalSource table key name PrimaryHelper::fresnsPrimaryId()
aidStringoptionalAccount parameter file_usages->account_id
Stored as aid converted to accounts->id
uidNumberoptionalUser parameter file_usages->user_id
Stored as uid converted to users->id
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
moreJsonStringoptionalCustom
fileFilerequiredFile
  • Either tableId or tableKey must be passed.
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        // Common Data Structure -> File Info
    }
}
Logic Notes

uploadFileInfo

php
\FresnsCmdWord::plugin('Fresns')->uploadFileInfo($wordBody);
Parameter NameTypeRequiredDescription
platformIdNumberrequiredPlatform number (key value from the configuration table platforms)
usageTypeNumberrequiredFile usage type
tableNameStringrequiredSource table name
tableColumnStringrequiredSource field name
tableIdNumberoptionalSource table primary id
tableKeyStringoptionalSource table key name PrimaryHelper::fresnsPrimaryId()
aidStringoptionalAccount parameter file_usages->account_id
Stored as aid converted to accounts->id
uidNumberoptionalUser parameter file_usages->user_id
Stored as uid converted to users->id
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
fileInfoArrayrequiredFile information array
  • Either tableId or tableKey must be passed.
fileInfo Example
json
[
    {
        "name": "Store to files->name",
        "mime": "Store to files->mime",
        "extension": "Store to files->extension",
        "size": "Store to files->size", // Unit Byte
        "md5": "Store to files->md5",
        "sha": "Store to files->sha",
        "shaType": "Store to files->sha_type",
        "path": "Store to files->path",
        "imageWidth": "Image specific, store to files->image_width",
        "imageHeight": "Image specific, store to files->image_height",
        "videoTime": "Video specific, store to files->video_time",
        "videoPosterPath": "Video specific, store to files->video_poster_path",
        "audioTime": "Audio specific, store to files->audio_time",
        "transcodingState": "Audio and video specific, Store to files->transcoding_state",
        "moreJson": {
            // Extended information, store to files->more_json
        },
        "originalPath": "Store to files->original_path",
        "rating": "Store to file_usages->rating",
    }
]
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": [
        {
            // Common Data Structure -> File Info
        },
        {
            // Common Data Structure -> File Info
        }
    ]
}
Logic Notes

getAntiLinkFileInfo (One)

php
\FresnsCmdWord::plugin('Fresns')->getAntiLinkFileInfo($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
fileIdOrFidStringoptionalfiles->id or files->fid
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        // Common Data Structure -> File Info
    }
}
Logic Notes
  • If hotlink protection is not enabled, the encapsulated function in the model can be used to output information.
  • $file->getFileInfo();

getAntiLinkFileInfoList (Multiple)

php
\FresnsCmdWord::plugin('Fresns')->getAntiLinkFileInfoList($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
fileIdsOrFidsArrayoptionalfiles->id or files->fid
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": [
        {
            // Common Data Structure -> File Info
        },
        {
            // Common Data Structure -> File Info
        }
    ]
}
Logic Notes
  • If hotlink protection is not enabled, the encapsulated function can be used to output information.
  • FileHelper::fresnsFileInfoListByIds('fileIdsOrFids');

getAntiLinkFileOriginalUrl

php
\FresnsCmdWord::plugin('Fresns')->getAntiLinkFileOriginalUrl($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
fileIdOrFidStringoptionalfiles->id or files->fid
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        "originalUrl": "Concatenated from file->original_path field",
        // When original_path is empty, concatenate from files->path field as a substitute
    }
}
Logic Notes
  • If hotlink protection is not enabled, the encapsulated function in the model can be used to output information.
  • $file->getFileOriginalUrl();

logicalDeletionFiles

php
\FresnsCmdWord::plugin('Fresns')->logicalDeletionFiles($wordBody);
Parameter NameTypeRequiredDescription
fileIdsOrFidsArrayrequiredfiles->id or files->fid

physicalDeletionFiles

php
\FresnsCmdWord::plugin('Fresns')->physicalDeletionFiles($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
fileIdsOrFidsArrayrequiredfiles->id or files->fid
  • The file types in the fileIds or fids array must belong to the same type category.

Released under the Apache-2.0 License