summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHannes Rosenögger <123haynes@gmail.com>2015-02-14 19:52:45 +0100
committerDouwe Maan <douwe@gitlab.com>2015-02-17 22:21:13 +0100
commit9729cc584f5758395960416f308a9c45f698cdee (patch)
treee4b45ad34333e1a9ca9035bfddf5e7d2ef56932c /app
parentca504a77fe994da893cd0632de5e0e7ea5b729fc (diff)
downloadgitlab-ce-9729cc584f5758395960416f308a9c45f698cdee.tar.gz
implement Project::UploadsController
Diffstat (limited to 'app')
-rw-r--r--app/controllers/files_controller.rb29
-rw-r--r--app/controllers/projects/uploads_controller.rb16
-rw-r--r--app/uploaders/file_uploader.rb4
3 files changed, 21 insertions, 28 deletions
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index a86340dd9bb..15523cbc2e7 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -1,5 +1,5 @@
class FilesController < ApplicationController
- def download_notes
+ def download
note = Note.find(params[:id])
uploader = note.attachment
@@ -14,32 +14,7 @@ class FilesController < ApplicationController
not_found!
end
else
- not_found!
+ redirect_to uploader.url
end
end
-
- def download_files
- namespace_id = params[:namespace]
- project_id = params[:project]
- folder_id = params[:folder_id]
- filename = params[:filename]
- project_with_namespace="#{namespace_id}/#{project_id}"
- filename_with_id="#{folder_id}/#{filename}"
-
- project = Project.find_with_namespace(project_with_namespace)
-
- uploader = FileUploader.new("#{Rails.root}/uploads","#{project_with_namespace}/#{folder_id}")
- uploader.retrieve_from_store!(filename)
-
- if can?(current_user, :read_project, project)
- download(uploader)
- else
- not_found!
- end
- end
-
- def download(uploader)
- disposition = uploader.image? ? 'inline' : 'attachment'
- send_file uploader.file.path, disposition: disposition
- end
end
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
new file mode 100644
index 00000000000..1c9fb1c86fb
--- /dev/null
+++ b/app/controllers/projects/uploads_controller.rb
@@ -0,0 +1,16 @@
+class Projects::UploadsController < Projects::ApplicationController
+ layout 'project'
+
+ before_filter :project
+
+ def show
+ folder_id = params[:folder_id]
+ filename = params[:filename]
+
+ uploader = FileUploader.new("#{Rails.root}/uploads","#{@project.path_with_namespace}/#{folder_id}")
+ uploader.retrieve_from_store!(filename)
+
+ disposition = uploader.image? ? 'inline' : 'attachment'
+ send_file uploader.file.path, disposition: disposition
+ end
+end
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index ac7bd5b27ec..51ae8040e52 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -40,7 +40,9 @@ class FileUploader < CarrierWave::Uploader::Base
end
def secure_url
- Gitlab.config.gitlab.relative_url_root + "/files/#{@path}/#{@filename}"
+ path_array = @path.split('/')
+ path = File.join(path_array[0],path_array[1],'uploads',path_array[2])
+ Gitlab.config.gitlab.relative_url_root + "/#{path}/#{@filename}"
end
def image?