class Marten::DB::Field::File
- Marten::DB::Field::File
- Marten::DB::Field::Base
- Reference
- Object
Overview
Represents a file field.
Defined in:
marten/db/field.crmarten/db/field/file.cr
marten/db/field/file/file.cr
Constructors
Instance Method Summary
-
#default : String?
Returns the default value of the field if any.
-
#empty_value?(value) : ::Bool
Returns
true
if the value is considered empty by the field. -
#from_db(value) : Marten::DB::Field::File::File | Nil
Converts the raw DB value to the corresponding field value.
-
#from_db_result_set(result_set : ::DB::ResultSet) : Marten::DB::Field::File::File | Nil
Extracts the field value from a DB result set and returns the right object corresponding to this value.
-
#max_size : Int32
Returns the max size of the string corresponding to the file path to be stored in the database.
-
#prepare_save(record, new_record = false)
Runs pre-save logic for the specific field and record at hand.
- #sanitize_filename(filename : ::String) : ::String
-
#storage
Returns the storage object that should be used to store the file.
-
#to_column : Management::Column::Base | Nil
Returns a migration column object corresponding to the field at hand.
-
#to_db(value) : ::DB::Any
Converts the field value to the corresponding DB value.
-
#upload_to : String -> String | String
Returns the path where the file should be stored or a proc returning this path.
Instance methods inherited from class Marten::DB::Field::Base
blank? : Bool
blank?,
db_column
db_column,
db_column! : ::String
db_column!,
db_column?
db_column?,
default
default,
empty_value?(value) : ::Bool
empty_value?,
from_db(value)
from_db,
from_db_result_set(result_set : ::DB::ResultSet)
from_db_result_set,
getter_value?(value) : ::Bool
getter_value?,
id : String
id,
index? : Bool
index?,
null? : Bool
null?,
prepare_save(record, new_record = false)
prepare_save,
primary_key? : Bool
primary_key?,
related_model
related_model,
relation?
relation?,
relation_name
relation_name,
to_column : Management::Column::Base | Nil
to_column,
to_db(value) : ::DB::Any
to_db,
truthy_value?(value)
truthy_value?,
unique? : Bool
unique?,
validate(record, value)
validate
Constructor methods inherited from class Marten::DB::Field::Base
new(id : ::String, primary_key : ::Bool = false, blank : ::Bool = false, null : ::Bool = false, unique : ::Bool = false, index : ::Bool = false, db_column : ::String | Symbol | Nil = nil)
new
Constructor Detail
Instance Method Detail
Returns the default value of the field if any.
Returns true
if the value is considered empty by the field.
Converts the raw DB value to the corresponding field value.
Extracts the field value from a DB result set and returns the right object corresponding to this value.
Returns the max size of the string corresponding to the file path to be stored in the database.
Runs pre-save logic for the specific field and record at hand.
This method does nothing by default but can be overridden for specific fields that need to set values on the model instance before save or perform any pre-save logic.
Returns a migration column object corresponding to the field at hand.
Converts the field value to the corresponding DB value.
Returns the path where the file should be stored or a proc returning this path.