File repository

6 Replies, 111 Views

I think we might need a separate file repository outside the standard MyBB mechanism (MyBB streams all attachments using a separate PHP process!!!!)

Implementation-wise, the easiest way is:
- create a directory tree on the webserver
- upload big files (e.g. videos, audios, etc) in that directory structure
- use either MyBB tags or auto-embedding to insert the direct links into posts

The result:
- no dependency on PHP/MyBB/authentication
- maximum performance
- minimum CPU/RAM load
- best search engine indexing

Looks easy and simple (and it is), but everything must be done by myself. For example:

- someone uploads a file
- I download it
- I remove it from the post
- I rename it and upload it into a specific directory
- I edit the post and insert the direct link

Any ideas how to automate it?
I think the best option for end users is to rewrite the mybb attachments system to do this uploading to the file server instead and make some minor edits to the post creator to handle these changes gracefully. This would make any PHP a one time "cost" per attachment and the user post flow would be virtually unchanged.

Its easy to say "just rewrite it" but I really don't think there are any better options. Anything else would end up quite hacky compared to a one time migration of existing attachments and a fix directly at upload time.

There are some questions though:
How do you plan to lay out the directory? Segmented by user uploads? by thread? how will you programmatically handle conflicts?
if there is no mybb auth how are private message attachments handled? (is the directory open, are filenames easy to guess etc?)
(Yesterday, 02:34 )dhf7b8g Wrote: I think the best option for end users is to rewrite the mybb attachments system t
Ideally - absolutely. It can be done as a plugin, though I'm not sure. The idea behind the MyBB implementation of the attachment system is the granular access. In our forum, currently, everything is open to everybody, except the archive (it's hidden from the search engines).

My simple idea was to move only big files, say, 15MB+ and videos to the separate file repository, and leave all usual images as they are an where they are.
You can simply use filesize https://www.php.net/manual/en/function.filesize.php and move bigger files somewhere else. no need for extra plugins.
(Yesterday, 22:13 )krinlyc Wrote: You can simply use filesize https://www.php.net/manual/en/function.filesize.php and move bigger files somewhere else. no need for extra plugins.
It will break the access from the forum.
Why?

You mount that other storage as a new directory to the directory structure of the forum.

No breaks. On Unix you can use ln ( link ) for that.
OK, this what the upload directory for March 2026 (separate directory per month) looks like:

. . .
post_22922_1773056843_1f188db756eb0cf19152f2b29dc58853.attach
post_22922_1773056843_1f188db756eb0cf19152f2b29dc58853_thumb.jpeg
post_29789_1772351273_f68e5176f8b1f9f571cb50de1b6dd26c.attach
post_32543_1772827814_2a5d0517b39e20aaafb5ba74fb5a24a7.attach
post_33595_1772456502_a2516d9f0fa6ec1f6f678befd3d7f1cc.attach
post_33595_1772456502_a2516d9f0fa6ec1f6f678befd3d7f1cc_thumb.png
post_7696_1772754284_037aeb680b2e3a35a9b0973160656463.attach
post_7696_1772754284_037aeb680b2e3a35a9b0973160656463_thumb.gif
. . .

If you move only big files out of it, you have to create a symbolic link for each and every moved file.

And it will not solve the main issue - streaming every attachment through a separate PHP process.
(This post was last modified: 1 hour ago by Like Ra.)

Possibly Related Threads…
Thread Author Replies Views Last Post
  Maximum file sizes madjack 1 631 03 May 2024, 12:20
Last Post: Like Ra