Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.9k 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
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).
...