You use an Eco.BlobType attribute when your model must hold binary large-object data, such as a document, image, audio file, video, or a large block of text.
What an Eco.BlobType attribute stores
A BLOB (Binary Large Object) is binary data managed as one value. Model an Eco.BlobType attribute when the application needs to retain the content itself rather than only a file name, URL, or other reference to content.
For example, a Document class can have an attribute named Content that holds the uploaded document data. A Product class can have an attribute that holds an image.
| Need | Model approach | Example |
|---|---|---|
| Store the file or image content in the model | Use an Eco.BlobType attribute. | Document.Content
|
| Store binary data without telling the user interface how to present it | Model the value as an untyped blob. | A downloaded archive or an application-specific binary format |
| Present the binary value as a specific kind of content | Set the blob type to the intended content type where applicable. | Set the type to Image for product artwork so the user interface shows it as an image.
|
| Keep large content outside the granular model database in Turnkey | Configure external blob storage. | A large uploaded document stored in App_Data/BlobStorage
|
Model a blob attribute
Create an attribute on the class that owns the content, then use Eco.BlobType as its data type.
For example, model these attributes on a Document class:
| Attribute | Purpose | Example value |
|---|---|---|
Name
|
Identifies the document to users. | Safety instructions
|
Content
|
Holds the document's binary data. | The uploaded PDF data |
ContentType
|
Records the content classification if your application needs it. | application/pdf
|
The Content attribute is the Eco.BlobType attribute. The model owns the data as one value; the application can then retrieve and handle that value as document content.
Choose a presentation type when it helps the user interface
A blob can be modeled as data with no presentation hint. Use this for content that the user interface should not treat as a particular visual format.
When the content has a known presentation, set its blob type accordingly. For example, set a product-picture attribute to Image when it contains image data. The user interface can then show the value as an image rather than as unspecified binary content.
Do not use an image presentation type for arbitrary files. For example, a PDF attachment is document data, not image data, even if its first page contains a picture.
Store large blobs outside the model database
Blob storage lets Turnkey keep large files out of the granular model database. To use it, add the following tagged value to the blob, text, or image attribute:
ExternalBlobStorage = true
With the out-of-the-box implementation, Turnkey stores the files on disk in:
App_Data/BlobStorage
The stored file name follows this pattern:
Class.Attribute.Guid.blob
For example, content from Document.Content is stored using a name in the form:
Document.Content.<Guid>.blob
Important limits
- External blob storage is Turnkey functionality only.
- Files in the default blob-storage location are not automatically cleaned. Plan how your application or operational process will remove content that is no longer needed.
- The tagged value applies to blob, text, and image attributes.
Persistence and type mapping
Eco.BlobType participates in the same model-to-runtime and persistence concepts as other attribute types. Type mapping and OR-mapping describes how attribute type names resolve to .NET types and how persistence mappers control database handling. Keep the attribute's PersistenceMapper at <Default> unless the attribute has a defined persistence requirement that calls for a specific mapper.
Example: product image
A product catalog needs one image per product.
- Add an
Imageattribute toProductusing Eco.BlobType. - Set the blob type to
Imageso the user interface presents the binary value as an image. - If the catalog images are large and the application is a Turnkey application, add
ExternalBlobStorage = trueto the attribute. - Define a cleanup process for images that are replaced or for products that are removed.
This keeps the model focused on the product and its image while allowing Turnkey external blob storage to keep the large image content outside the granular model database.
See also
- Documentation:Blob
- Documentation:BlobStorage
- Documentation:Type mapping, OR-Mapping
- Documentation:Column.Texttype
- Documentation:Introduction to ECO
[[Category:Attributes and data types [Beginner]]]
