[opencms-dev] file management
脸谱
afeinet at 163.com
Mon Jul 8 07:35:48 CEST 2019
Finally see others have this need, share my experience here.
Last year, I also had the idea of storing some large files directly on disks outside the database.And then I did it myself.
The implementation principle is like this, for example, to store a 1G MP4 file,
Store the data directly on disk when uploading files;
Store the file path stored on disk as the contents of the VFS file for OpenCMS;(At the front of this stored path I used a few special letters "REFS::" do the mark)
When the end user accesses this file, the contents of the VSF file are first read from inside the database, and then the first few bytes are taken to determine if it is "REFS::", at this point the file data on the disk is read directly to return to the client.
At the time, I fully implemented these features, and it was configured to decide what files could be stored on disk rather than in the database.
I've added this configuration to opencms-vfs.xml (by the file name suffix):
<filecontent>
<handle>
<!-- If you have these file suffixes, drivers stored to disk are used. -->
<driver class="org.opencms.file.content.refs.CmsFileContentDriver">
<param name="refs.marker">REFS::</param>
<param name="refs.storage">../REFS-DISK1</param>
</driver>
<extension value=".mp3"/>
<extension value=".mp4"/>
<extension value=".rar"/>
<extension value=".zip"/>
<extension value=".exe"/>
<extension value=".pdf"/>
</handle>
<handle>
<!-- Otherwise, using the default implementation, the content is stored in the database. -->
<driver class="org.opencms.file.content.CmsFileContentDriver" />
</handle>
</filecontent>
And to implement such a function, modify a large number of code, also passed the test, the actual operation did not have a problem.
Of course, this approach may be completely different from what officials mentioned before, although they have now given up on implementing this feature. If someone is interested in this, I can share the code that implements this feature.
--
缘起法实不可思议也。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20190708/499125d6/attachment.htm>
More information about the opencms-dev
mailing list