This repository has been archived by the owner on May 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Uploading Files
Florian Kasper edited this page Jul 19, 2014
·
1 revision
Since version 1.5.13 GollumRails has the ability to upload files directly into your GIT repository.
You can define a model, where you can customize your uploads further:
app/models/upload.rb
class Upload < GollumRails::Upload
end
# Signature: #initialize(file:SomeSortOfRackFileupload , destination:String)
# File is a Rack file upload:
# <input type="file" name="file" />
upload = Upload.new(file: params[:file], destination: 'uploads')
upload.save #or save! if you want exceptions to be thrown instead of returning false
OR:
upload = Upload.create(file: params[:file], destination: 'uploads')
You can easily blacklist Files by extension name. e.g. file.tar.gz
has the extension .gz
.
class Upload < GollumRails::Upload
blacklist_format :gz, :png
end
class Upload < GollumRails::Upload
whitelist_format :tar, :bz2
end
class Upload < GollumRails::Upload
max_filesize 2.megabytes
end
class Upload < GollumRails::Upload
upload_directory 'uploads'
end
now you don't need to append your destination to your instance call anymore:
upload = Upload.create(file: params[:file])