diff --git a/app/assets/stylesheets/generic/files.scss b/app/assets/stylesheets/generic/files.scss
index 6607ae327e077463f4f29f116cecfaa80ff6b624..11bb715f7b5b1dec6766a722f7e616e669844636 100644
--- a/app/assets/stylesheets/generic/files.scss
+++ b/app/assets/stylesheets/generic/files.scss
@@ -45,7 +45,7 @@
       text-align: center;
       img {
         padding: 100px;
-        max-width: 300px;
+        max-width: 50%;
       }
     }
 
diff --git a/app/contexts/files/create_context.rb b/app/contexts/files/create_context.rb
index b3d62a028c72fc6d92a4c10f375783dc9ab8fdcc..3b684d3ee92b602f894091106cb659488310251d 100644
--- a/app/contexts/files/create_context.rb
+++ b/app/contexts/files/create_context.rb
@@ -33,7 +33,8 @@ module Files
       new_file_action = Gitlab::Satellite::NewFileAction.new(current_user, project, ref, file_path)
       created_successfully = new_file_action.commit!(
         params[:content],
-        params[:commit_message]
+        params[:commit_message],
+        params[:encoding]
       )
 
       if created_successfully
diff --git a/app/contexts/files/update_context.rb b/app/contexts/files/update_context.rb
index 556027a3256802166406add8baca0e1fcd33aed8..8f0185df74d8e69a894b25180c5a4bc1bd4e9671 100644
--- a/app/contexts/files/update_context.rb
+++ b/app/contexts/files/update_context.rb
@@ -23,10 +23,11 @@ module Files
         return error("You can only edit text files")
       end
 
-      new_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path)
-      created_successfully = new_file_action.commit!(
+      edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path)
+      created_successfully = edit_file_action.commit!(
         params[:content],
-        params[:commit_message]
+        params[:commit_message],
+        params[:encoding]
       )
 
       if created_successfully
diff --git a/app/views/projects/new_tree/show.html.haml b/app/views/projects/new_tree/show.html.haml
index 078a4b80d0d5f95df2c43f91872ee21a82324cf8..9d7c7afbeac2c4cba10624998a3054eb851a4efc 100644
--- a/app/views/projects/new_tree/show.html.haml
+++ b/app/views/projects/new_tree/show.html.haml
@@ -14,6 +14,12 @@
             on
             %span= @ref
 
+    .form-group.commit_message-group
+      = label_tag :encoding, class: "control-label" do
+        Encoding
+      .col-sm-10
+        = select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'form-control'
+
     .form-group.commit_message-group
       = label_tag 'commit_message', class: "control-label" do
         Commit message
diff --git a/doc/api/repositories.md b/doc/api/repositories.md
index 35f7ad7ae95854ad0baa957dd51100152120d673..0160726300893a179c723586b73265c0f9502932 100644
--- a/doc/api/repositories.md
+++ b/doc/api/repositories.md
@@ -400,6 +400,7 @@ Parameters:
 
 + `file_path` (optional) - Full path to new file. Ex. lib/class.rb
 + `branch_name` (required) - The name of branch
++ `encoding` (optional) - 'text' or 'base64'. Text is default.
 + `content` (required) - File content
 + `commit_message` (required) - Commit message
 
@@ -413,6 +414,7 @@ Parameters:
 
 + `file_path` (required) - Full path to file. Ex. lib/class.rb
 + `branch_name` (required) - The name of branch
++ `encoding` (optional) - 'text' or 'base64'. Text is default.
 + `content` (required) - New file content
 + `commit_message` (required) - Commit message
 
diff --git a/lib/api/files.rb b/lib/api/files.rb
index 6a5419a580f108025a9de0e8e0fdf82b039df82c..8e87ae52e645190b002043a4c7ad6df3b07c944b 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -18,7 +18,7 @@ module API
       #
       post ":id/repository/files" do
         required_attributes! [:file_path, :branch_name, :content, :commit_message]
-        attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message]
+        attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message, :encoding]
         branch_name = attrs.delete(:branch_name)
         file_path = attrs.delete(:file_path)
         result = ::Files::CreateContext.new(user_project, current_user, attrs, branch_name, file_path).execute
@@ -48,7 +48,7 @@ module API
       #
       put ":id/repository/files" do
         required_attributes! [:file_path, :branch_name, :content, :commit_message]
-        attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message]
+        attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message, :encoding]
         branch_name = attrs.delete(:branch_name)
         file_path = attrs.delete(:file_path)
         result = ::Files::UpdateContext.new(user_project, current_user, attrs, branch_name, file_path).execute
diff --git a/lib/gitlab/satellite/files/edit_file_action.rb b/lib/gitlab/satellite/files/edit_file_action.rb
index f410ecb79846991587fc001c82be6910fe24f9d3..cbdf70f7d129c10866b0a08e0882be7123be244c 100644
--- a/lib/gitlab/satellite/files/edit_file_action.rb
+++ b/lib/gitlab/satellite/files/edit_file_action.rb
@@ -10,7 +10,7 @@ module Gitlab
       # Returns false if committing the change fails
       # Returns false if pushing from the satellite to bare repo failed or was rejected
       # Returns true otherwise
-      def commit!(content, commit_message)
+      def commit!(content, commit_message, encoding)
         in_locked_and_timed_satellite do |repo|
           prepare_satellite!(repo)
 
@@ -26,7 +26,8 @@ module Gitlab
             return false
           end
 
-          File.open(file_path_in_satellite, 'w') { |f| f.write(content) }
+          # Write file
+          write_file(file_path_in_satellite, content, encoding)
 
           # commit the changes
           # will raise CommandFailed when commit fails
diff --git a/lib/gitlab/satellite/files/file_action.rb b/lib/gitlab/satellite/files/file_action.rb
index 0f7afde647d9bb2f5839090ab92df07d0c614ce8..7701a6d5d608ea1759a7df6819a468c390dff79f 100644
--- a/lib/gitlab/satellite/files/file_action.rb
+++ b/lib/gitlab/satellite/files/file_action.rb
@@ -12,6 +12,14 @@ module Gitlab
       def safe_path?(path)
         File.absolute_path(path) == path
       end
+
+      def write_file(abs_file_path, content, file_encoding = 'text')
+        if file_encoding == 'base64'
+          File.open(abs_file_path, 'wb') { |f| f.write(Base64.decode64(content)) }
+        else
+          File.open(abs_file_path, 'w') { |f| f.write(content) }
+        end
+      end
     end
   end
 end
diff --git a/lib/gitlab/satellite/files/new_file_action.rb b/lib/gitlab/satellite/files/new_file_action.rb
index 57d101ff535d914ece38ffb1ae50aa1009a93984..15e9b7a6f77555471910088deff2a231533179ec 100644
--- a/lib/gitlab/satellite/files/new_file_action.rb
+++ b/lib/gitlab/satellite/files/new_file_action.rb
@@ -9,7 +9,7 @@ module Gitlab
       # Returns false if committing the change fails
       # Returns false if pushing from the satellite to bare repo failed or was rejected
       # Returns true otherwise
-      def commit!(content, commit_message)
+      def commit!(content, commit_message, encoding)
         in_locked_and_timed_satellite do |repo|
           prepare_satellite!(repo)
 
@@ -29,7 +29,7 @@ module Gitlab
           FileUtils.mkdir_p(dir_name_in_satellite)
 
           # Write file
-          File.open(file_path_in_satellite, 'w') { |f| f.write(content) }
+          write_file(file_path_in_satellite, content, encoding)
 
           # add new file
           repo.add(file_path_in_satellite)