Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of Hash in Nginx Upload module?

Tags:

nginx

hash

upload

I have made the Nginx Upload working normally with Python (Tornado). I save the paths of the uploaded files in the database.

However, I wonder why the upload module has to split my uploads and put them into 10 different folders /var/www/.../uploads/0,1,2,3,4,5...9 ? The comment below says the files were hashed, what and why the module does this?

  # Store files to this directory
  # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
  upload_store /var/www/...uploads 1;
like image 733
MK Yung Avatar asked Sep 17 '25 03:09

MK Yung


1 Answers

# filesystem location where we store uploads
#
# The second argument is the level of "hashing" that nginx will perform
# on the filenames before storing them to the filesystem. I can't find
# any documentation online, so as an example, say we were using this
# configuration:
#
#   upload_store /tmp/uploads 2 1;
#
# A file named '43829042' would be written to this path:
#
#   /tmp/uploads/42/0/43829042
#
# I hope that's clear enough. The argument is required and must be
# greater than 0. You can see the implementation here:
#
#  http://lxr.evanmiller.org/http/source/core/ngx_file.c#L118

Source: http://bclennox.com/extremely-large-file-uploads-with-nginx-passenger-rails-and-jquery

like image 185
Christoph Geschwind Avatar answered Sep 19 '25 13:09

Christoph Geschwind