| 1 |
Apache upload progress module. Works with mod_passenger (aka mod_rails). It's MIT license. |
| 2 |
|
| 3 |
More info here: http://drogomir.com/blog/2008/6/18/upload-progress-bar-with-mod_passenger-and-apache |
| 4 |
|
| 5 |
Tutorials showing how to use apache upload progress module: |
| 6 |
http://www.drogomir.com/blog/2008/7/3/tweaking-rails-app-with-jquery-part-i (using jQuery) |
| 7 |
http://www.railsillustrated.com/screencast-file-uploads-progress-in-rails-passenger.html (tutorial with screencast using prototype) |
| 8 |
|
| 9 |
To install and activate module: |
| 10 |
apxs2 -c -i -a mod_upload_progress.c |
| 11 |
|
| 12 |
-c -> compile |
| 13 |
-i -> install (copy upload_progress_module.so to apache lib folder) |
| 14 |
-a -> activate (add LoadModule line to httpd.conf) |
| 15 |
|
| 16 |
On Macs: |
| 17 |
apxs -c -i -a -Wc,"-arch i386 -arch x86_64" -Wl,"-arch i386 -arch x86_64" mod_upload_progress.c |
| 18 |
|
| 19 |
Missing compiler directory: |
| 20 |
|
| 21 |
If you get this error: |
| 22 |
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain/usr/bin/cc: No such file or directory |
| 23 |
create a symlink before compiling: |
| 24 |
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain |
| 25 |
|
| 26 |
OS X 10.11 El Capitan with System Integrity Protection (SIP): |
| 27 |
|
| 28 |
You will get this error when installing: |
| 29 |
install: /usr/libexec/apache2/mod_upload_progress.so: Operation not permitted |
| 30 |
You can work around that by creating a custom directory and copy the file over after compiling: |
| 31 |
mkdir /usr/local/libexec/apache2 |
| 32 |
cp .libs/mod_upload_progress.so /usr/local/libexec/apache2/mod_upload_progress.so |
| 33 |
You can then manually reference this location in your httpd.conf file: |
| 34 |
LoadModule upload_progress_module /usr/local/libexec/apache2/mod_upload_progress.so |
| 35 |
|
| 36 |
Global config: |
| 37 |
you can define maximum size for shared memory (default is 50kB): |
| 38 |
UploadProgressSharedMemorySize 1024000 # sets memory size to 1MB |
| 39 |
|
| 40 |
Note: |
| 41 |
If you get "(12)Cannot allocate memory: Upload Progress cache: could not create shared memory segment Configuration Failed" |
| 42 |
error you should try to set memory size to smaller value. |
| 43 |
|
| 44 |
Config for vhost (or global locations): |
| 45 |
<Location /> |
| 46 |
# enable tracking uploads in / |
| 47 |
TrackUploads On |
| 48 |
</Location> |
| 49 |
|
| 50 |
<Location /progress> |
| 51 |
# enable upload progress reports in /progress |
| 52 |
ReportUploads On |
| 53 |
</Location> |
| 54 |
|
| 55 |
- Valid progress ID |
| 56 |
Progress IDs are now validated: length must be within 8..128 characters, |
| 57 |
identifier may contain alphanumeric characters and also -_:./!{} |
| 58 |
|
| 59 |
- JSON-P Support |
| 60 |
You can also request progress updates by using JSON-P, if you are uploading |
| 61 |
the file from a different domain or subdomain than the web server that is |
| 62 |
handling your original request. Adding a "callback=yourCallbackFunction" |
| 63 |
parameter to your request to the progress server will activate this functionality. |
| 64 |
|
| 65 |
For example, a request like: |
| 66 |
http://uploads.yourdomain.com/progress?callback=jsonp123&X-Progress-ID=12345678 |
| 67 |
|
| 68 |
Would return the JSON-P function: |
| 69 |
jsonp123({ "state" : "uploading", "received" : 35587, "size" : 716595, "speed" : 35587, "started_at": 1296568823, "uuid" : "12345678" }); |
| 70 |
|
| 71 |
The normal JSON request: |
| 72 |
http://www.yourdomain.com/progress?X-Progress-ID=12345678 |
| 73 |
|
| 74 |
Would return the JSON data: |
| 75 |
{ "state" : "uploading", "received" : 35587, "size" : 716595, "speed" : 35587, "started_at": 1296568823, "uuid" : "12345678" } |
| 76 |
|
| 77 |
- Valid JSON-P callbacks |
| 78 |
Callback names are now validated: length must be within 1..64 characters |
| 79 |
identifier may contain alphanumeric characters and also ._$ |