Storage Plugin Development
- Storage Service Provider Configuration
Panel > Systems > Storage
- View plugin configuration information
Path Rules
FileHelper::fresnsFileStoragePath($fileType, $usageType);
Command Word
The main program interacts with the storage plug-in through command words, so the storage plug-in mainly implements the following command words.
Command Word | Description |
---|---|
getUploadToken | Get Upload Token |
uploadFile | upload File |
uploadFileInfo | Upload File Information |
getAntiLinkFileInfo | Get information about anti-theft link file [one] |
getAntiLinkFileInfoList | Get information about anti-theft link file[Multiple] |
getAntiLinkFileOriginalUrl | Get the source file anti-theft link |
logicalDeletionFiles | Logical Deletion Files |
physicalDeletionFiles | Physical Deletion Files |
As for the function of file-related command words and parameter instructions, please refer to development support.
Upload Page
The access path to the plugin upload page is configured in the accessPath
parameter of the plugin.json
file for operators and users to upload files using the plugin page after configuration.
Since the Fresns API and editor use the basic form upload mode, there is a risk of timeout interruptions for large files. The storage plugin can provide an upload page that integrates JS-SDK on the plugin page to implement slicing and breakpoint uploads for large files.
- Path Reference
/qiniu/upload?sign={sign}&config={uploadInfo}&postMessageKey={postMessageKey}
- Introduction of variable names in paths
Audio and video functions
- Transcoding command word triggered reactively.
- Such three tables as
posts
,comments
, andconversation_messages
shall be subscribed to when installing the plug-in. When there are any newly-added contents, trigger the transcoding command word and scan whether there are any audio/video files. - If there are any audios/videos and transcoding is not performed (
transcoding_state = 1
), execute transcoding.
Transcoding Configuration
- As for videos of file type
2
, execute transcoding according to thevideo_transcode
key value in the configuration table. - As for audios of file type
3
, execute transcoding according to theaudio_transcode
key value in the configuration table.
Transcoding Process
- Wait for the subscription function of the main program to trigger you (notification your command word of the table state you subscribed)
- Your command word is triggered. Inquire file content attachment with
primaryId
.
file_usages->file_type
=2
video,3
audiofile_usages->table_name
= table namefile_usages->table_column
= column name, post, comment, conversation message, is IDfile_usages->table_id
=primaryId
- The procedure should suspend if there is no attachment.
- Your command word is triggered. Inquire file content attachment with
- Inquire the transcoding state
files->transcoding_state
- 3.1
transcoding_state = 1
to be transcoded: the procedure continues; - 3.2
transcoding_state = 2
transcoding: transcoding is being performed and the procedure suspends; - 3.3
transcoding_state = 3
transcoded: transcoding is completed and the procedure suspends; - 3.4
transcoding_state = 4
transcoding failed and the procedure suspends;
- Inquire the transcoding state
- Execute transcoding and modify file subsidiary table field as
transcoding_state = 2
at the same time.
- Execute transcoding and modify file subsidiary table field as
- Accept the call-back notification from the cloud service provider.
- 5.1 Transcoding performed successfully:
- 5.1.1 Fill the transcoded file name into the
files->path
- 5.1.2 Fill the source file path before transcoding into
files->original_path
- 5.1.3 Replace the new file information (this step could be neglected if there is no relevant new information)
files->mime
files->extension
files->size
files->md5
files->sha
files->sha_type
- 5.1.4 Modify the transcoding state as
files->transcoding_state = 3
- 5.1.1 Fill the transcoded file name into the
- 5.2 Transcoding failed
- 5.2.1 Modify the transcoding state as
files->transcoding_state = 4
- 5.2.2 If there are any other parameters or notes that failed to be transcoded, fill them into the
files->transcoding_reason
field.
- 5.2.1 Modify the transcoding state as
File Information Structure
File Information
use App\Models\File;
$file->getFileInfo();
Example of information
{
"fid": "files->fid",
"type": "files->type",
"status": "files->is_enabled",
"substitutionImageUrl": "File expiration alert image",
"sensitive": "files->is_sensitive",
"name": "files->name",
"mime": "files->mime",
"extension": "files->extension",
"size": "files->size",
"md5": "files->md5",
"sha": "files->sha",
"shaType": "files->sha_type",
"moreJson": {
// files->more_json
},
// Image Parameters
"imageWidth": "files->image_width",
"imageHeight": "files->image_height",
"imageLong": "files->image_is_long",
"imageConfigUrl": "image_bucket_domain + files->path + image_thumb_config",
"imageRatioUrl": "image_bucket_domain + files->path + image_thumb_ratio",
"imageSquareUrl": "image_bucket_domain + files->path + image_thumb_square",
"imageBigUrl": "image_bucket_domain + files->path + image_thumb_big",
// Video Parameters
"videoTime": "files->video_time",
"videoPosterUrl": "video_bucket_domain + file->video_poster_path",
"videoUrl": "video_bucket_domain + files->path",
// Audio Parameters
"audioTime": "files->audio_time",
"audioUrl": "audio_bucket_domain + files->path",
// Document Parameters
"documentPreviewUrl": "Links after replacement by rule",
// Audio and Video Parameter
"transcodingState": "files->transcoding_state"
}
Link to Original File
use App\Models\File;
$file->getFileOriginalUrl();