summaryrefslogtreecommitdiffstats
path: root/lib/redmine/utils.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-14 08:20:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-14 08:20:32 +0000
commit035edd39c422c9434147a1b0ac457cb9383c9b5b (patch)
tree4b25e158e04068c535e828c04f336c769ac9db9c /lib/redmine/utils.rb
parent763d5dddde2c7dda03fe529c9dfe0d553669c277 (diff)
downloadredmine-035edd39c422c9434147a1b0ac457cb9383c9b5b.tar.gz
redmine-035edd39c422c9434147a1b0ac457cb9383c9b5b.zip
Import issues from CSV file (#950).
git-svn-id: http://svn.redmine.org/redmine/trunk@14493 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/utils.rb')
-rw-r--r--lib/redmine/utils.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/redmine/utils.rb b/lib/redmine/utils.rb
index 56350052f..ed27d7e84 100644
--- a/lib/redmine/utils.rb
+++ b/lib/redmine/utils.rb
@@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+require 'fileutils'
+
module Redmine
module Utils
class << self
@@ -40,6 +42,25 @@ module Redmine
def random_hex(n)
SecureRandom.hex(n)
end
+
+ def save_upload(upload, path)
+ directory = File.dirname(path)
+ unless File.exists?(directory)
+ FileUtils.mkdir_p directory
+ end
+ File.open(path, "wb") do |f|
+ if upload.respond_to?(:read)
+ buffer = ""
+ while (buffer = upload.read(8192))
+ f.write(buffer)
+ yield buffer if block_given?
+ end
+ else
+ f.write(upload)
+ yield upload if block_given?
+ end
+ end
+ end
end
module Shell