lib/condo/configuration.rb in condo-0.0.1 vs lib/condo/configuration.rb in condo-1.0.0
- old
+ new
@@ -6,18 +6,29 @@
include Singleton
@@callbacks = {
#:resident_id # Must be defined by the including class
:bucket_name => proc {"#{Rails.application.class.parent_name}#{instance_eval @@callbacks[:resident_id]}"},
- :object_key => proc {params[:file_name]},
+ :object_key => proc {
+ if params[:file_path]
+ params[:file_path] + params[:file_name]
+ else
+ params[:file_name]
+ end
+ },
:object_options => proc {{:permissions => :private}},
:pre_validation => proc {true}, # To respond with errors use: lambda {return false, {:errors => {:param_name => 'wtf are you doing?'}}}
:sanitize_filename => proc {
params[:file_name].tap do |filename|
filename.gsub!(/^.*(\\|\/)/, '') # get only the filename (just in case)
filename.gsub!(/[^\w\.\-]/,'_') # replace all non alphanumeric or periods with underscore
end
+ },
+ :sanitize_filepath => proc {
+ params[:file_path].tap do |filepath|
+ filepath.gsub!(/[^\w\.\-\/]/,'_') # replace all non alphanumeric or periods with underscore
+ end
}
#:upload_complete # Must be defined by the including class
#:destroy_upload # the actual delete should be done by the application
#:dynamic_residence # If the data stores are dynamically stored by the application
}
@@ -74,10 +85,10 @@
if options[:location].present?
@@locations[namespace][name][options[:location].to_sym] = res
else
@@locations[namespace][name][:default] = res
- @@locations[namespace][name][res.location] = res
+ @@locations[namespace][name][res.location.to_sym] = res
end
end
end
\ No newline at end of file