Added file uploader

Uploaded map files will be saved in /redmine/public/data

refs #16
This commit is contained in:
2012-04-26 10:56:28 -04:00
parent 6bbf73a85a
commit 228ff2b8d4
4 changed files with 24 additions and 8 deletions

View File

@@ -22,4 +22,16 @@
# if not a new bug issue will be generated.
class Map < ActiveRecord::Base
unloadable
require 'digest/sha1'
def self.save(upload)
name = upload['datafile'].original_filename
directory = "public/data"
sha1 = Digest::SHA1.hexdigest name
# create the file path
path = File.join(directory, sha1)
# write the file
File.open(path, "wb") { |f| f.write(upload['datafile'].read) }
end
end