Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+10 votes
2.1k views
in Q2A Core by
It works slower. Nginx faster, gives statics than working on a php script + the query to the database. Photo profiles, pictures in questions and answers, if the user base 100.000 + 1.000.000 with photos - it will be a heavy load on the cpu/web server/database server?
Q2A version: 1.8
by
This has already been discussed a couple of times. Just change it in qa-config.php
by
I did so, the files did appear in the created folder but in the page code, and the links to the files still look like this

/?qa=image&qa_blobid=8009133904088384912&qa_size=52
/?qa=blob&qa_blobid=12670555884355512663
by
The database keeps track of the uploaded blobs. If you want to change that behavior you will have to override the functions in qa-include/app/blobs.php with a custom plugin
by
But is it a big issue? Just one more server request for images -- that too for uncached.
by
Thanks for your reply. So now every request to every static file is a request to the script and database? Am I right?
by
Not every static file. In fact, I wouldn't call blobs static files. The blobs are uploaded by the users. If you serve the blobs as static files with a direct link to the file you lose Q2A's power. Plugins could modify how blobs are read so Q2A checks that before serving the file. You could have some permission check before accessing the file, which you can't have with a static file.
by
I found the plugin https://github.com/q2apro/q2apro-better-upload-folders but it doesn't work. Who can help? Thank
by
I understand you, but what is the default permission check before accessing? If the access check is not necessary, it may be worth simplifying it, especially if there are a lot of questions and pictures in the system. And now, even search engines every time refer to the script and the database, which in web applications and so the weakest link. Tell me if I'm wrong
by
> what is the default permission check before accessing?
There is none. As I mentioned, that's something you could add or any other user who has the need could add by using plugins, which you can use because Q2A is in the middle between the end user and the file. If you remove Q2A you remove features.

Again, if for you specific needs you want to save some database requests you can override the functions in qa-include/app/blobs.php with a custom plugin. You don' t have to convince anyone for you to do that... you can do it on your own... that's the power of plugins :)
by
I asked the programmers about blobs and got the answer that it was because the developer was lazy :)
by
Let me ask someone else in 2018, uses blobs only because it may sometime be necessary? :)
by
Please give an example of when you need checkpermission before accessing to the profile picture on the web sites questions and answers :) Standard project don't need that. It's not the banking system to hide pictures. Here we need to give information to the user as quickly as possible and with less server resources. Make a request to the database to get a picture? LOL Have a better option? Yes! Use the plugin :) there Was 10 request to the database will be 20. Very good solution! :) Maybe just put the files in a folder and the web server or proxy server will give the user bypassing the core, plugins and database? And for those who need the power of Q2A, check access rights and so on, can use the plugin.
by
And one more. Resources with a "?" in the URL are not cached by some proxy caching servers.
by
Plugin q2a-hide-users-list uses this image blob feature to hide avatars from anonymous visitors.

It is required for personal data protection.

I agree that images should not be stored in database but should be accessible only via script.
by
why hide avatars?
by
Avatars often contain personal information like photos.
by
reshown by
+1
I repeat, most sites questions and answers to hide the avatar is not necessary! Why upload an avatar to the Internet to hide it later? For what?
by
+1
Answer is quite simple: access control.
If something is there it does not mean everyone should see it.

For example, you provided your email address to this site, but I cannot see it. Admin can.

On sites I admin, users do upload avatars but they do not want neither avatars nor their names to to be visible to ANONYMOUS visitors of the site. They want that level of privacy.

2 Answers

0 votes
by
Every static request is a request to the script and (filesystem | database) -- second can be configured.
by
+1
Do you know how to do what I need?

Home page https://gateoverflow.in/ has
276 requests (Vancouver, Canada)  :) 17,3 sec and page size 4.9 MB.
216 Requests Washington DC, Load time 4.73 s
230 Requests Australia Sydney, Load time 13.74 s
218 Requests from London, Load time 6.51 s

And this is with more than 20K visitors per day!
You don't like your users?
Have you heard anything about website optimization? :) If not, ask me how :)
by
@Putin , what about https://gateoverflow.net/ :)
by
this is small site on bluehost
+3 votes
by

Firstly, do note that you can store the images themselves on disk, if you set the config option and the folder permissions. There’s also a button on the Admin > Stats page to move existing blobs from database to disk.

But the link to the image still uses the database. There are a few reasons for that:

  • Storing in the database means images can be used without any extra config like setting folder permissions.
  • It links each image to a user, so even if they don’t use the image in a post you can see who uploaded it (useful for spam).
  • It stores other information such as upload date (which may not be available if you copy or move files around).
  • It allows images to be resized on the fly - look at your avatar for example, it’s shown at different sizes in different places but is only stored once. If you changed the sizes in settings you don’t need to regenerate thousands of files.
  • It allows for permissions checking and other features as mentioned above.

You are correct that “most sites don’t need the extra functionality”, but it’s also not future-proof. If we use direct image links, then there is no easy way to add the other options to the old files in the future.

Having said that, I can certainly see valid reasons for linking files directly. The biggest stumbling block would be the image resizing, for which I cannot think of any good solution. If you have one let me know.

by
+1
"you can see who uploaded it" - That's the most valuable reason to have the DB take care of this. You can also list image uploads by user. And the upload date mentioned.

The only issue I have currently: How to read/store the images from an external block storage. Can I call the ?qa-blob=... link to load the image from the external server without any load to my main server?

Related: https://www.question2answer.org/qa/50346/
...