File
How to locate the record to which the file is attached by file name in a worksheet?
- Query by file name saved in object store
- Query by file name when uploaded
Take the filename saved in the object store as example
bR2HbXfudAfo9JafdveE4K0C9J2g519Gae3d4I84820k8a9Bee3t5I914q5J4p6e.pdf
Go to MongoDB's mdattachment to query the corresponding docid.
> use mdattachment
> db.attachment.find({"name": "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf"}).pretty()
{
"_id" : ObjectId("6413d880840db440e5f5a7be"),
"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"server" : "https://hap.domain.com/file/mdoc/",
"oFilename" : "APaaS测试文件",
"path" : "doc/20230317/",
"name" : "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf",
......
}
-
Get the
docid:a234f6ca-6bf2-4491-9261-e24758376b91 -
The
oFilenamehere is also the actual name of the file saved in the record of the worksheet.
Take the name of the file when it is uploaded as example:
APaaS test file.pdf.
Go to MongoDB's mdattachment to query corresponding docid.
> use mdattachment
# Exact query by file name
> db.attachment.find({"oFilename":"APaaS test file"}).pretty()
{
"_id" : ObjectId("6413d880840db440e5f5a7be"),
"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"server" : "https://hap.domain.com/file/mdoc/",
"oFilename" : "APaaS test file",
"path" : "doc/20230317/",
"name" : "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf",
......
}
# Fuzzy query by file name
> db.attachment.find({oFilename:{$regex:'.*PaaS.*'}}).pretty()
-
Get the
docid:a234f6ca-6bf2-4491-9261-e24758376b91 -
The
namehere is also the name of the file saved in object store.
Query the control ID in the relationship table by docid.
> db.attachmentrelation.find({"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91"}).pretty()
{
"_id" : ObjectId("6448eb672d71e11d04aae297"),
"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fType" : 9,
"pids" : [
"eaf823e5-4205-44fd-8521-109d3ec29a92"
],
"ctime" : ISODate("2023-04-26T09:14:15.289Z"),
"sourceid" : "bac739dc-9f8f-4ea5-a1f8-bdea56d27b81",
"commentid" : "6448eb5c12053cf665be2131"
}
- If
fType = 9,thencommentidis the control id,sourceidis the record id. - The control id obtained
commentidis6448eb5c12053cf665be2131 - The record id obtained
sourceidisbac739dc-9f8f-4ea5-a1f8-bdea56d27b81sourceidcorresponds torowidof the corresponding worksheet inmdwsrows.commentidcorresponds tocidin thewscontrolsinmdworksheet.
Query worksheet ID by commentid in wscontrols of mdworksheet.
> use mdworksheet
switched to db mdworksheet
> db.wscontrols.find({cid:"6448eb5c12053cf665be2131"}).pretty()
{
"_id" : ObjectId("6448eb5c12053cf665be2136"),
"cid" : "6448eb5c12053cf665be2131",
"wsid" : "6448eb5c12053cf665be212e",
......
}
wsidcorresponds to the worksheet id. So the worksheet id obtained is6448eb5c12053cf665be212e
Visit the following in your browser: System address/worksheet/worksheet ID, to access the worksheet where the queried file is attached.
Visit the following in your browser: System address/worksheet/worksheet ID/row/record ID, to access the record where the queried file is attached.
- Example: https://hap.domain.com/worksheet/6448eb5c12053cf665be212e/row/bac739dc-9f8f-4ea5-a1f8-bdea56d27b81
How to Enable Physical File Deletion
By default, deleted files are not physically removed from object storage. To clean up deleted files, add the following environment variables:
| Environment variable | Description | Default value |
|---|---|---|
ENV_FILE_DELETE_ENABLE_PHYSICAL | Whether to enable physical file deletion | false |
ENV_FILE_DELETE_BEFORE_DAYS | Takes effect only when ENV_FILE_DELETE_ENABLE_PHYSICAL is true. Specifies how many days after deletion a file is physically deleted. | 7 |
ENV_FILE_DELETE_TASK_CRON | Takes effect only when ENV_FILE_DELETE_ENABLE_PHYSICAL is true. Specifies the scheduled task execution time. | 0 0 1 * * ? (1:00 AM daily) |
After physical file deletion is enabled, files deleted in the following scenarios are also physically deleted:
| Status | Scenario |
|---|---|
| ✅ Supported | Delete an attachment from an attachment field on the record details page. |
| ✅ Supported | Manually delete a single record and empty the recycle bin. |
| ✅ Supported | Manually delete records on the current page and empty the recycle bin. |
| ❌ Not supported | Select the current page in a list, choose Edit, and clear attachment fields in bulk. |
| ❌ Not supported | Select all data in a list, choose Edit, and clear attachment fields in bulk. |
| ✅ Supported | In a workflow Update Record node, clear an attachment field for a single record. |
| ✅ Supported | In a workflow Update Record node, clear an attachment field for multiple records. |
| ✅ Supported | Update an attachment through the API with an Update Record node, choosing to overwrite data and remove the old attachment. |
| ❌ Not supported | Delete a single record through the API. |
| ❌ Not supported | Delete multiple records through the API. |
| ❌ Not supported | Manually delete all records and empty the recycle bin. |
| ❌ Not supported | Delete a single record in a workflow without moving it to the recycle bin. |
| ❌ Not supported | Delete multiple records in a workflow without moving them to the recycle bin. |
| ❌ Not supported | Delete an entire worksheet directly. |
| ❌ Not supported | Delete an entire application directly. |
In scenarios marked “Not supported”, attachment status cannot be tracked during bulk record deletion, so the corresponding attachments cannot be physically deleted.