File Upload
This page explains the current Geelato file upload capability, including upload entry points, storage modes, attachment metadata tables, and OSS configuration.
The description is based on:
UploadControllerFileHandlerUploadServiceAttachment
Overall Flow
The main upload entry is:
POST /api/upload/file
The runtime flow is:
UploadControllerreceives the upload request- it calculates the save path from
tableType / tenantCode / appId / root / isRename - it builds
FileParam FileHandlerchooses local storage or Aliyun OSS byserviceType- the binary content is stored
- attachment metadata is persisted through
AccessoryHandler - an
Attachmentis returned
So the framework clearly separates:
- binary storage
- attachment metadata persistence
Upload Entry
Standard File Upload
API:
POST /api/upload/file
Important parameters include:
fileserviceTypetableTyperootisRenameobjectIdformIdsgenrebatchNoinvalidTimevalidDurationisThumbnailonlyThumbdimensionthumbScaleappIdtenantCode
The most important ones are:
serviceType- chooses local or OSS storage
tableType- marks the attachment source
root- overrides the local root directory
isRename- decides whether the original filename is replaced with a UID
Object and JSON Upload
The runtime also provides:
POST /api/upload/objectPOST /api/upload/jsonPOST /api/upload/model/{entityName}/{id}
These are not normal attachment uploads. They write serialized content into:
geelato.upload.config-directory
File Storage Location
Local Root Directories
Local storage is controlled by:
geelato.upload.root-directorygeelato.upload.convert-directorygeelato.upload.config-directory
They are initialized in UploadService as static roots.
How the Path Is Built
For standard uploads without a custom root, the runtime usually uses:
UploadService.getRootSavePath(...)
The path usually contains:
- the upload root
- the attachment source such as
attach tenantCode/appId- a date-based directory
- the final filename
Custom Root
If root is passed in the request, the runtime switches to:
UploadService.getSaveRootPath(root, fileName, isRename)
So the file goes directly under the requested directory instead of the default upload root layout.
Local and OSS Storage
FileHandler is the actual storage dispatcher.
The rule is simple:
serviceType = aliyunmeans OSS- otherwise it falls back to local storage
Local Storage
In local mode:
- the file is written to disk
Attachment.pathstores the local absolute pathAttachment.objectIdis normally empty
OSS Storage
In OSS mode:
FileHelper.putFile(...)uploads to Aliyun OSS- OSS returns
objectIdandobjectName - attachment metadata is then saved
Attachment.pathstores the OSS object nameAttachment.objectIdstores the OSS object ID
So path is not always a local path. When objectId is present, the file is usually stored in OSS.
Thumbnail Support
Image uploads can enable:
isThumbnail
The current behavior includes:
- only image files generate thumbnails
- multiple thumbnail resolutions are supported
onlyThumb=truecan keep only the thumbnail records- parent-child relations are linked through
pid
Attachment Metadata
The framework stores file metadata through:
Attachment
Important fields include:
idpidappIdnametypegenresizepathobjectIdformIdsinvalidTimebatchNoresolution
Actual Metadata Tables
Runtime attachment queries aggregate three tables:
platform_attachplatform_compressplatform_resources
They are unified as one Attachment view for the upper layer.
The SQL also derives:
storageType = aliyunstorageType = local
from the presence of object_id.
OSS Configuration
Aliyun OSS configuration comes from:
properties/oss.properties
Key properties are:
geelato.oss.accessKeyIdgeelato.oss.accessKeySecretgeelato.oss.endPointgeelato.oss.bucketNamegeelato.oss.region
In quickstart they are normally injected through environment variables.
If OSS is not configured and serviceType is set to aliyun, FileHandler throws a clear error.
Related Attachment APIs
After upload, attachment metadata can be managed through AttachController, including:
POST /api/attach/copy/{id}POST /api/attach/quote/{id}GET /api/attach/get/{id}POST /api/attach/update/{id}POST /api/attach/listPOST /api/attach/pageQueryDELETE /api/attach/remove/{id}POST /api/attach/storage/{type}GET /api/resources/file?id={id}&isPreview=true
Notes:
resources/filereturns the file content by attachmentidisPreview=truetypically returns preview-friendly content type for images/PDFs