Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated docs

  • Loading branch information...
commit 32ec0e18f3d604850f465ba23237ab86825a569e 1 parent 651098e
Daniel Tenner authored

Showing 1 changed file with 26 additions and 9 deletions. Show diff stats Hide diff stats

  1. +26 9 README.textile
35 README.textile
Source Rendered
@@ -33,15 +33,15 @@ end
33 33 And add the following to your nginx config:
34 34
35 35 <pre>
36   -location /upload
37   -{
  36 +location /upload {
  37 +
  38 + client_max_body_size 2048m;
  39 +
38 40 # Pass altered request body to this location
39   - # NTW: This seems to be ignored and the above location is used instead
40   - upload_pass /dummy;
  41 + upload_pass /process_upload;
41 42
42 43 # Store files to this directory
43   - # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
44   - upload_store /tmp/uploads 1;
  44 + upload_store /tmp/uploads;
45 45
46 46 # Allow uploaded files to be read by everyone
47 47 upload_store_access user:rw group:rw all:rw;
@@ -54,19 +54,23 @@ location /upload
54 54
55 55 upload_pass_form_field "^_session_id$";
56 56 upload_pass_form_field "^folder[id]$";
  57 +
  58 + break;
57 59 }
58 60
59 61 # dummy location that needs to be defined. :-(
60   -location /dummy
61   -{
  62 +location /process_upload {
  63 + client_max_body_size 2048m;
  64 + proxy_pass http://upstream_server;
  65 + break;
62 66 }
63 67 </pre>
64 68
65 69 Worth noting (from "here":http://www.motionstandingstill.com/nginx-upload-awesomeness/2008-08-13/):
66 70
67 71 * You have to explicitly tell nginx what fields to pass, if there are additional fields, on top of the file itself (and there likely will be things like session id)
68   -* The upload_pass command is ignored in v2.04 of the module, but you still have to include it
69 72 * The location that you post to has to be of a direct route, off root - not /controller/action
  73 +* make sure you include the <code>client_max_body_size</code> and the <code>break</code>s, or you may hit problems.
70 74
71 75 h2. Schema setup
72 76
@@ -82,3 +86,16 @@ t.string "original_filename"
82 86 t.datetime "deleted_at"
83 87 </pre>
84 88
  89 +h2. How are the files stored?
  90 +
  91 +Num-Fu stores the files in whatever directory you pass as the <code>path_prefix</code> option. It organises them in subdirectories so that there are no more than 256 files per subdirectory. The folder structure is capable of supporting up to 10000 * 10000 * 256 = 25.6 billion files, via a structure like:
  92 +
  93 +<pre>
  94 + 0001/0001/c35e6f0358ce7390-IMG_A.JPG
  95 + 0001/0025/d0a706593750e972-IMG_B.JPG
  96 + 0123/0123/dcc3b7d5fc5e146f-IMG_C.JPG
  97 +</pre>
  98 +
  99 +The folder structure will start at 0001/0001 and fill out all the way until 9999/9999. I have _not_ tested what happens when you exceed that limit... if you are storing 25 billion files, however, I would suggest you look into writing your own storage handling code (perhaps S3 storage might be more appropriate than filesystem storage).
  100 +
  101 +The 16-alphanumeric-digit random string prepended to each filename is there to ensure, within reason, that there are no collisions between files with the same name. It is technically possible that two files uploaded with the same filename around the same time will end up in the same directory and overwrite each other. However, based on the usage patterns that we are seeing on Woobius, it's probably more productive to worry about the Earth exploding spontaneously.

0 comments on commit 32ec0e1

Please sign in to comment.
Something went wrong with that request. Please try again.