Hello Guys,
I have an idea about a mechanism for uploaded files pluged into rails
and wanted to ask for
some advise here.
The idea is, that all uploaded files could be stored with an unique
id in the filesystem or
database with the file metas like mime type, size and filename.
All you save in your model should be the id of the uploaded file.
There could
be an form_tag helper like <%= vault_file ''product'',
''product_image''
%> which handels the
the Model metas vault_file :product_image and
validates_vault_file_mime_type :product_image, :with => %w{ image/
jpeg image/gif }
If a model object has already an uploaded file the vault_file tag
should present an "delete file"
and the uploaded filename plus the upload form tag for overwriting
the existing file.
The uploaded file could be accessed with something like http://xyz/
download_vault/passcode/123 or
http://xyz/image_vault/passcode/123
Further ideas are that with storing it into db there could be
something like uploaded file distribution
for some clustered environments or virus checks for uploaded files.
So the gound idea is that rails could handle the vault_file form_tag
and the vault metas for the model.
I am an not very expericenced with with extending rails so i ask here
for some design
advises howto code something like that, all i have figured out at
this moment is that i could
extend the ActiveRecod:Base, ActionView:Helpers:FormHelper and the
Validations:ClassMethods.
I am willing to learn with an extension like this the internas of
rails and the magics of ruby.
Maybe someone have some suggestions or want to guide me or could show
some examples.
Greetings,
Marc Beyerlin