uploaded files are stored in random nested directories
This commit is contained in:
parent
e1cd5a0ef4
commit
d875ae2367
|
@ -20,10 +20,6 @@ server {
|
|||
client_body_timeout 5s;
|
||||
client_header_timeout 5s;
|
||||
|
||||
# Auto generate a uuid for each file. This means users are able to upload
|
||||
# Skyfiles without having to provide a uuid
|
||||
rewrite ^/skynet/skyfile/?$ /skynet/skyfile/$request_id$1;
|
||||
|
||||
# NOTE: make sure to enable any additional configuration you might need like gzip
|
||||
|
||||
location / {
|
||||
|
@ -56,11 +52,23 @@ server {
|
|||
proxy_pass http://127.0.0.1:9980/skynet/stats;
|
||||
}
|
||||
|
||||
location /skynet/skyfile/ {
|
||||
location /skynet/skyfile {
|
||||
limit_conn uploads_by_ip 10; # ddos protection: max 10 uploads at a time
|
||||
client_max_body_size 1000M; # make sure to limit the size of upload to a sane value
|
||||
proxy_read_timeout 600;
|
||||
|
||||
# Extract 3 sets of 2 characters from $request_id and assign to $dir1, $dir2, $dir3
|
||||
# respectfully. The rest of the $request_id is going to be assigned to $dir4.
|
||||
# We use those variables to automaticallygenerate unique path for uploaded file, yet
|
||||
# we want to limit the number of folders on one directory level so we create nested path.
|
||||
# Example path result: /af/24/9b/c5ec894920ccc45634dc9a8065
|
||||
if ($request_id ~* "(\w{2})(\w{2})(\w{2})(\w+)") {
|
||||
set $dir1 $1;
|
||||
set $dir2 $2;
|
||||
set $dir3 $3;
|
||||
set $dir4 $4;
|
||||
}
|
||||
|
||||
# proxy this call to siad endpoint (make sure the ip is correct)
|
||||
#
|
||||
# note that we point uploads to port '9970', do this when you want to
|
||||
|
@ -70,7 +78,7 @@ server {
|
|||
# siad setup, make sure only the download portal runs in 'portal mode'.
|
||||
# The upload siad can be run in normal mode. Set the port to '9980' if
|
||||
# you do not want to run your portal in the double siad setup.
|
||||
proxy_pass http://127.0.0.1:9970;
|
||||
proxy_pass http://127.0.0.1:9970/skynet/skyfile/$dir1/$dir2/$dir3/$dir4;
|
||||
|
||||
proxy_set_header Expect $http_expect;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
|
|
Reference in New Issue