diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-11-09 22:01:26 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-11-10 12:51:51 +0100 |
commit | db3213fc1c653b20783f9a41074eaf17132010de (patch) | |
tree | 80668282d2ff9fd314d47bda96d3f53a4d31301d /lib/api/helpers.rb | |
parent | 7e4e3fb3b6177d2863580786e9ef6ee3a4ccf037 (diff) | |
download | gitlab-ce-db3213fc1c653b20783f9a41074eaf17132010de.tar.gz |
Use normal file upload mechanism to upload artifacts
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 077537959d7..92540ccf2b1 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -294,19 +294,23 @@ module API # file helpers - def uploaded_file!(uploads_path) - required_attributes! [:file] + def uploaded_file!(field, uploads_path) + if params[field] + bad_request!("#{field} is not a file") unless params[field].respond_to?(:filename) + return params[field] + end # sanitize file paths - # this requires for all paths to exist + # this requires all paths to exist + required_attributes! %W(#{field}.path) uploads_path = File.realpath(uploads_path) - file_path = File.realpath(params[:file]) + file_path = File.realpath(params["#{field}.path"]) bad_request!('Bad file path') unless file_path.start_with?(uploads_path) UploadedFile.new( file_path, - params[:filename], - params[:filetype] || 'application/octet-stream', + params["#{field}.name"], + params["#{field}.type"] || 'application/octet-stream', ) end |