summaryrefslogtreecommitdiff
path: root/app/services/lfs
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-05-06 12:51:49 +0000
committerNick Thomas <nick@gitlab.com>2019-05-06 12:51:49 +0000
commite20e062737631e37904b54c73539e6846cd5a1e7 (patch)
tree7f43714d2d4f7e6bf7b60736a943925dcf1ff0c0 /app/services/lfs
parent38d57a61b6d960b2997578a0a12a40fa686c30ea (diff)
downloadgitlab-ce-e20e062737631e37904b54c73539e6846cd5a1e7.tar.gz
Fix uploading of LFS tracked file through UI
Diffstat (limited to 'app/services/lfs')
-rw-r--r--app/services/lfs/file_transformer.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/services/lfs/file_transformer.rb b/app/services/lfs/file_transformer.rb
index 6ecf583cb6a..5239fe1b6e3 100644
--- a/app/services/lfs/file_transformer.rb
+++ b/app/services/lfs/file_transformer.rb
@@ -24,7 +24,7 @@ module Lfs
def new_file(file_path, file_content, encoding: nil)
if project.lfs_enabled? && lfs_file?(file_path)
- file_content = Base64.decode64(file_content) if encoding == 'base64'
+ file_content = parse_file_content(file_content, encoding: encoding)
lfs_pointer_file = Gitlab::Git::LfsPointerFile.new(file_content)
lfs_object = create_lfs_object!(lfs_pointer_file, file_content)
@@ -66,5 +66,12 @@ module Lfs
def link_lfs_object!(lfs_object)
project.lfs_objects << lfs_object
end
+
+ def parse_file_content(file_content, encoding: nil)
+ return file_content.read if file_content.respond_to?(:read)
+ return Base64.decode64(file_content) if encoding == 'base64'
+
+ file_content
+ end
end
end