Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-12-06 14:36:11 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-12-07 14:27:52 +0300
commitf7c18ca31469b199c1a898cef583c9aae99f1375 (patch)
tree72182129a81d996a886ea765514d20bc7e2bcf8c /app/uploaders
parentfe62860e05ca6e3ef7125fe92fdf52cd6f7b63df (diff)
Support uploads for groups
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/file_uploader.rb8
-rw-r--r--app/uploaders/namespace_file_uploader.rb15
2 files changed, 19 insertions, 4 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index 71658df5b41..0b591e3bbbb 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -29,11 +29,11 @@ class FileUploader < GitlabUploader
# model - Object that responds to `full_path` and `disk_path`
#
# Returns a String without a trailing slash
- def self.dynamic_path_segment(project)
- if project.hashed_storage?(:attachments)
- dynamic_path_builder(project.disk_path)
+ def self.dynamic_path_segment(model)
+ if model.hashed_storage?(:attachments)
+ dynamic_path_builder(model.disk_path)
else
- dynamic_path_builder(project.full_path)
+ dynamic_path_builder(model.full_path)
end
end
diff --git a/app/uploaders/namespace_file_uploader.rb b/app/uploaders/namespace_file_uploader.rb
new file mode 100644
index 00000000000..672126e9ec2
--- /dev/null
+++ b/app/uploaders/namespace_file_uploader.rb
@@ -0,0 +1,15 @@
+class NamespaceFileUploader < FileUploader
+ def self.base_dir
+ File.join(root_dir, '-', 'system', 'namespace')
+ end
+
+ def self.dynamic_path_segment(model)
+ dynamic_path_builder(model.id.to_s)
+ end
+
+ private
+
+ def secure_url
+ File.join('/uploads', @secret, file.filename)
+ end
+end