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

What is currently happening with v1.6.3:

  1. Image file gets uploaded and gets assigned a blobid (20 digits)
  2. Example blob id "15015929639481993982"
  3. a folder is created by the first 3 digits: /150/
  4. the filename is created within this folder as "15015929639481993982.jpeg".

I am certain that this structure needs improvement to be human readable.

My suggestion:

  1. take the upload date as the folder name, e.g. "2014-07-27" (also available in table blobid, field created)
  2. and upload all images from this day into this folder.
  3. naming it with the blobid

If somebody is concerned that after x years there are hundreds of folders, we could use a folder for each year, then inside a subfolder with month and day, for instance "2014/07/27".

If you see any disadvantages with my approach, please let me know. Otherwise I would like gidgreen or scott to implement this new way, if possible.

-----

Update:

Since I could not wait, I wrote a plugin that implements this structure: https://github.com/q2apro/q2apro-better-upload-folders

Q2A version: 1.7

1 Answer

+1 vote
by

Why use a date? I'm not sure there is any value in storing files in a dated folder, especially if files will be linked to multiple times on later dates.

I think pupi's arguments from the other thread still apply here. Using a set structure means the distribution of files across the folders will be roughly even. The username/userid is also a no-go IMO for the same reasons.

There are two problems with the current system that I see:

  1. Using 3 digits means the blobs folder will have up to 1000 subfolders. Can be a problem when browsing in FTP etc. This could be solved using a similar approach to Wikipedia: first a single-digit folder, then a two-digit folder. So your example above would be /1/50/15015929639481993982.jpg
  2. The filenames themselves are meaningless. Images with proper names would be better for users as well as SEO. Something like /1/50/my-image.jpg. (One concern would be improper names but we could potentially use the word censor to fix that.)

 What do you think?

by
edited by
By using the dates we have 1. a distribution over folders/time 2. a humanreadable approach.

"especially if files will be linked to multiple times on later dates."
No, the folder is set only regarding the upload date. The upload folder will hold subfolders for years, e.g. 2016, 2017, etc. which again hold months 1-12, which hold days. Example: 2016/01/30/filename.jpg (which is loaded/referenced by qa_blobs by a blob id I hope).


The current approach is IMO not good at all from a human POV: 1. Not readable. 2. Not understandable (folder structure).

I like the current approach of number ids. Do not keep the filenames. I am not even sure if the Google bot cares. It cares more about the alt tag.
by
Hi Scott, will there be a change of the upload structure soon? I probably have to go for the file system instead the DB and really want to use another structure, a structure that can be understood...

Ref: https://github.com/q2a/question2answer/issues/258
by
edited by
I thought we can also leave the current approach because I can get all the necessary file information from the blobs table. But since each uploaded file gets a blob entry with a "created" we could really use that :)

PS: http://www.question2answer.org/qa/50049/moving-all-blobs-from-database-to-filesystem-distinct
by
Since I could not wait, I wrote a plugin that implements this structure: https://github.com/q2apro/q2apro-better-upload-folders

@Scott: Feel free to implement the code into the q2a core or parts of it.

Greetings :)
by
Got one important reason for the date structure: BACKUP! In case you have only a simple FTP client (like me) and suppose you cannot install other software, how do you backup newly added files, copy all 30k files again? Nope, easy as that: You have the month folder (or day folder) and can only copy this without the issue of missing one of the files. Awesome :)
by
Most FTP clients have an option when you download to only download new files (i.e. those which do not exist on your computer already).
...