- Updated `GetText` and `SaveText` methods to support both full content and a preview (first 2000 characters) for improved performance and usability. - Added comprehensive tests in `manager_test.go` to validate the new functionality, including UTF-8 character handling and content retrieval scenarios. - Modified the attachment model to include a `content_preview` field alongside the existing `content` field, ensuring efficient data management. - Enhanced the README.md to document the new dual storage feature, providing clear examples for users on how to utilize the updated methods.
208 lines
4.6 KiB
Text
208 lines
4.6 KiB
Text
{
|
|
"name": "attachment",
|
|
"label": "Attachment",
|
|
"description": "Attachment table for storing file attachments with metadata and access control",
|
|
"tags": ["system"],
|
|
"builtin": true,
|
|
"readonly": true,
|
|
"sort": 9999,
|
|
"table": {
|
|
"name": "attachment",
|
|
"comment": "Attachment table"
|
|
},
|
|
"columns": [
|
|
{
|
|
"name": "id",
|
|
"type": "ID",
|
|
"label": "Attachment ID",
|
|
"comment": "Unique attachment identifier"
|
|
},
|
|
{
|
|
"name": "file_id",
|
|
"type": "string",
|
|
"label": "File ID",
|
|
"comment": "File identifier",
|
|
"length": 255,
|
|
"nullable": false,
|
|
"unique": true,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "uploader",
|
|
"type": "string",
|
|
"label": "Uploader",
|
|
"comment": "File uploader type",
|
|
"length": 200,
|
|
"nullable": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "content_type",
|
|
"type": "string",
|
|
"label": "Content Type",
|
|
"comment": "File content type",
|
|
"length": 200,
|
|
"nullable": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "content",
|
|
"type": "longText",
|
|
"label": "Content",
|
|
"comment": "Full parsed text content from image, pdf, word and other file types",
|
|
"nullable": true
|
|
},
|
|
{
|
|
"name": "content_preview",
|
|
"type": "text",
|
|
"label": "Content Preview",
|
|
"comment": "Preview of parsed text content (first 2000 characters)",
|
|
"nullable": true
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "string",
|
|
"label": "Name",
|
|
"comment": "File name",
|
|
"length": 500,
|
|
"nullable": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "url",
|
|
"type": "string",
|
|
"label": "URL",
|
|
"comment": "File URL",
|
|
"length": 1000,
|
|
"nullable": true,
|
|
"index": false
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "string",
|
|
"label": "Description",
|
|
"comment": "File description",
|
|
"length": 1000,
|
|
"nullable": true,
|
|
"index": false
|
|
},
|
|
{
|
|
"name": "type",
|
|
"type": "string",
|
|
"label": "Type",
|
|
"comment": "File type",
|
|
"length": 200,
|
|
"nullable": true,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "user_path",
|
|
"type": "string",
|
|
"label": "User Path",
|
|
"comment": "User-specified complete file path",
|
|
"length": 1000,
|
|
"nullable": true,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "path",
|
|
"type": "string",
|
|
"label": "Storage Path",
|
|
"comment": "Actual storage path for the file",
|
|
"length": 1000,
|
|
"nullable": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "groups",
|
|
"type": "json",
|
|
"label": "Groups",
|
|
"comment": "File groups",
|
|
"nullable": true
|
|
},
|
|
{
|
|
"name": "gzip",
|
|
"type": "boolean",
|
|
"label": "Gzip",
|
|
"comment": "Whether file is gzipped",
|
|
"default": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "bytes",
|
|
"type": "bigInteger",
|
|
"label": "Bytes",
|
|
"comment": "File size in bytes",
|
|
"nullable": false,
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "status",
|
|
"type": "enum",
|
|
"label": "Status",
|
|
"comment": "File processing status",
|
|
"option": [
|
|
"uploading",
|
|
"uploaded",
|
|
"indexing",
|
|
"indexed",
|
|
"upload_failed",
|
|
"index_failed"
|
|
],
|
|
"default": "uploading",
|
|
"index": true
|
|
},
|
|
{
|
|
"name": "progress",
|
|
"type": "string",
|
|
"label": "Progress",
|
|
"comment": "Processing progress information",
|
|
"length": 200,
|
|
"nullable": true
|
|
},
|
|
{
|
|
"name": "error",
|
|
"type": "string",
|
|
"label": "Error",
|
|
"comment": "Error information",
|
|
"length": 600,
|
|
"nullable": true
|
|
},
|
|
|
|
{
|
|
"name": "preset",
|
|
"type": "boolean",
|
|
"label": "Preset Attachment",
|
|
"comment": "Whether this is a preset attachment",
|
|
"default": false,
|
|
"nullable": false
|
|
},
|
|
|
|
{
|
|
"name": "public",
|
|
"type": "boolean",
|
|
"label": "Public Attachment",
|
|
"comment": "Whether this attachment is shared across all teams in the platform",
|
|
"default": false,
|
|
"nullable": false
|
|
},
|
|
|
|
// Custom permissions
|
|
{
|
|
"name": "share",
|
|
"type": "enum",
|
|
"label": "Share",
|
|
"comment": "Attachment sharing scope",
|
|
"option": [
|
|
"private", // Only visible to the owner
|
|
"team" // Visible to all team members
|
|
],
|
|
"default": "private",
|
|
"nullable": false,
|
|
"index": true
|
|
}
|
|
],
|
|
"relations": {},
|
|
"indexes": [],
|
|
"option": { "timestamps": true, "soft_deletes": false, "permission": true }
|
|
}
|