Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
3.7k views
in Q2A Core by
edited by

The feature that can manage upload file on disk was added to Q2A V1.6. I report usage of this feature.

What?

The file (image) uploaded in CKEditor(etc) was stored to database conventionally, you can choose database or disk  from V1.6. Even if you choose disk, URL does not change. In other words, you can access files by old link(old link does not expire). Of course, there is data migration tool, too.

Where?

  1. Setting: qa-config.php define('QA_BLOBS_DIRECTORY', ...
  2. Button: admin -> stats -> "Blobs to disk"
  3. Button: admin -> stats -> "Blobs to database"

2 & 3 buttons nothing in my Q2A... frown

2 and 3 buttons are displayed on following condition.

  • button2: 1 is enable. AND data exit in database.
  • button3: 1 is enable. AND file exist  in folder1.

Which?

This is just guideline.

People who wants to keep database smaller should choose disk.
People who wants to make everyday backup only database should choose database.

Safety?

Because Q2A get from file system if data don't exist in database, even if you change destination, it is OK.

Last: necessary inspection

I don't yet know whether image access performance is improved by disk mode.

I'm glad if helpful to someone.

Q2A version: 1.6
by
How to configurate qa-config.php, I can't activate blobs buttons.

3 Answers

0 votes
by
,Hi
 
This might be a silly question but I would like to validate that I am not double storing
.the uploaded files both on the server and on the database
 
After I enabled this feature and the uploaded files appear in the target folder I can still see the uploaded files being also registered in the database the same way it used to before I enabled this feature - in the qtoa_blobs table
 
I would like to validate that this only mean that the uploaded files are in fact just registered on the database and that the files only get stored on the server (disk) without doubles
 
...and thank you for Q2A! :-)
by
Yes, that's right. If you store the files on disk it's just some metadata in the database, and the content column will be NULL.
by
Thanx Gideon!
by
Is that metadata for keeping track of uploaded files? i.e. which ones are in use etc
by
Not whether it's in use, but the file type, who uploaded it, when uploaded, etc...
+2 votes
by
I don't yet know whether image access performance is improved by disk mode.

Assuming that when they're saved to disk Q2A references the file directly, then yes it certainly is faster. The server will serve the file straight off, whereas with the database it needs to load PHP, which connects to MySQL and fetches the data. Servers like nginx are super fast at serving files straight from disk.

by
Thank you Scott.
by
Q2A does not reference the file directly, but reads-outputs it. This is because the QA_BLOBS_DIRECTORY is not restricted to something in the public web directory. Good idea for a future improvement though.
by
+1
Oh, okay... I thought the whole point of storing on disk instead of in the database was so you could reference the file directly.
by
Yes, there would be sense in that of course, but the impression I got was people's main concern was storing big lumps of data in the database. BTW all the BLOB functions can be overridden in a plugin :)
+1 vote
by

I don't yet know whether image access performance is improved by disk mode.

I investgated client cache a little by FireFox and Firebug. It seems that image (attachment) isn't cached in client (browser). I added source code, then images were cached in browser and requests decreased in my environment.

qa-include/qa-image.php (about L59):

header('Cache-Control: max-age=2592000, public'); // allows browsers and proxies to cache images too
header("Pragma: cache");  // <===== Add.

qa-include/qa-blob.php (about L56):

header('Cache-Control: max-age=2592000, public'); // allows browsers and proxies to cache images too
header("Pragma: cache");  // <===== Add.
Result may change by Web server and browser. How about in your environment?
by
edited by
Because images (include avatar) are not cached in the environment where web server does not is coordinated , I think Q2A V1.7 should include this correction. "Pragma: no-cache" seems to be transmitted by default in also HTTP1.1 protocol. And, client browser seems to apply "Pragma" for back compatibility.

http://www.electrictoolbox.com/php-caching-headers/
...