Skip to content

File Command Word

checkUploadPerm

php
\FresnsCmdWord::plugin('Fresns')->checkUploadPerm($wordBody);
Parameter NameTypeRequiredDescription
uidNumberrequiredUploader UID
usageTypeStringrequiredFile usage type
usageFsidStringrequiredUsage target fsid
archiveCodeStringoptionalelementType File Archive
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
extensionStringoptionalFile Extension Name
sizeNumberoptionalin Byte
durationNumberoptionalAudio or video duration in seconds
Usage Type and Fsid
usageTypeusageFsidarchiveCode
userAvatarUser uidOrUsername
userBannerUser uidOrUsername
userArchiveUser uidOrUsernameArchive code
conversationReceives the user uidOrUsername
postPost ID pid
commentComment ID comment
postDraftPost Draft ID did
postDraftArchivePost Draft ID didArchive code
commentDraftComment Draft ID did
commentDraftArchiveComment Draft ID didArchive code
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        "usageType": "Number / Type of File Usage",
        "tableName": "String / Table Name",
        "tableColumn": "String / Column Name",
        "tableId": "Number / Primary ID",
        "tableKey": "String / FSID",
        "maxUploadNumber": "Number / Max Upload Number"
    }
}

getUploadToken

php
\FresnsCmdWord::plugin('Fresns')->getUploadToken($wordBody);
Parameter NameTypeRequiredDescription
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
pathStringrequiredFile Path
minutesNumberrequiredActive Minutes
  • Get S3 presigned url
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        "type": "presignedUrl",
        "method": "String / Method",
        "url": "String / Endpoint URL",
        "headers": "Object / Headers",
        "activeMinutes": "Number / Active Minutes",
        "expiration": "String / Expiration Datetime Y-m-d H:i:s" // UTC+0
    }
}

uploadFile

php
\FresnsCmdWord::plugin('Fresns')->uploadFile($wordBody);
Parameter NameTypeRequiredDescription
fileFilerequiredFile
typeNumberrequired1.Image / 2.Video / 3.Audio / 4.Document
warningTypeNumberoptional1.No 2.Nudity 3.Violence 4.Sensitive
usageTypeNumberrequiredFile usage type
platformIdNumberrequiredPlatform number (key value from the configuration table platforms)
tableNameStringrequiredSource table name (which table is using)
tableColumnStringrequiredSource field name (which field is using)
tableIdNumberoptionalSource table primary id
tableKeyStringoptionalSource table key name PrimaryHelper::fresnsPrimaryId()
moreInfoObjectoptionalCustom Info
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
  • Either tableId or tableKey must be passed.
Return Example
json
{
    "code": 0,
    "message": "ok",
    "data": {
        // Common Data Structure -> File Info
    }
}

getTemporaryUrlFileInfo (One)

php
\FresnsCmdWord::plugin('Fresns')->getTemporaryUrlFileInfo($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 temporary url is not enabled, the encapsulated function in the model can be used to output information.
  • $file->getFileInfo();

getTemporaryUrlFileInfoList (Multiple)

php
\FresnsCmdWord::plugin('Fresns')->getTemporaryUrlFileInfoList($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 temporary url is not enabled, the encapsulated function can be used to output information.
  • FileHelper::fresnsFileInfoListByIds('fileIdsOrFids');

getTemporaryUrlOfOriginalFile

php
\FresnsCmdWord::plugin('Fresns')->getTemporaryUrlOfOriginalFile($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 temporary url 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