Added file uploader

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

refs #16
This commit is contained in:
ricky committed 2012-04-26 10:56:28 -04:00
1 parent 6bbf73a85a
commit 228ff2b8d4
4 files changed
+24 -8

No files matched your search

+12
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