class Marten::DB::Field::File::File
- Marten::DB::Field::File::File
- Reference
- Object
Included Modules
Defined in:
marten/db/field/file/file.crmarten/template/ext/marten/db/field/file/file.cr
Constructors
Instance Method Summary
-
#attached?
Returns
true
if a file is attached to the field and record. -
#committed? : Bool
Returns
true
if the file is committed to the underlying storage. -
#delete(save = false) : Nil
Deletes the associated filfe from the storage.
-
#file=(file : ::File | Marten::HTTP::UploadedFile | Nil)
Allows to associate a new file to the field.
-
#name : String?
Returns the name of the file or
nil
if no file is set. -
#open : IO
Returns a
IO
object allowing to interact with the file's content. -
#save(filepath : ::String, content : IO, save = false) : Nil
Allows to save a new file to the underlying storage.
-
#size : Int64
Returns the
#size
of the file. -
#url : ::String
Returns the URL of the file.
Macros inherited from module Marten::Template::CanDefineTemplateAttributes
template_attributes(*names)
template_attributes
Constructor Detail
Instance Method Detail
Deletes the associated filfe from the storage.
A Marten::DB::Errors::UnexpectedFieldValue
error is raised if no file is associated with this object.
Optionally, a #save
boolean can be set to force the associated record to be saved along the way.
Allows to associate a new file to the field.
Returns a IO
object allowing to interact with the file's content.
A Marten::DB::Errors::UnexpectedFieldValue
error is raised if no file is associated with this object.
Allows to save a new file to the underlying storage.
A filepath
string and a content
IO must be specified. Optionally, a #save
boolean can be set to force
the associated record to be saved along the way.
Returns the #size
of the file.
A Marten::DB::Errors::UnexpectedFieldValue
error is raised if no file is associated with this object.
Returns the URL of the file.
A Marten::DB::Errors::UnexpectedFieldValue
error is raised if no file is associated with this object.