Skip to main content

File

How to locate the record to which the file is attached by file name in a worksheet?​

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 oFilename here is also the actual name of the file saved in the record of the worksheet.

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,then commentid is the control id,sourceid is the record id.
  • The control id obtained commentid is 6448eb5c12053cf665be2131
  • The record id obtained sourceid is bac739dc-9f8f-4ea5-a1f8-bdea56d27b81
    • sourceid corresponds to rowid of the corresponding worksheet in mdwsrows.
    • commentid corresponds to cid in the wscontrols in mdworksheet.

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",
......
}
  • wsid corresponds to the worksheet id. So the worksheet id obtained is 6448eb5c12053cf665be212e

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.

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 variableDescriptionDefault value
ENV_FILE_DELETE_ENABLE_PHYSICALWhether to enable physical file deletionfalse
ENV_FILE_DELETE_BEFORE_DAYSTakes 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_CRONTakes 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:

StatusScenario
✅ SupportedDelete an attachment from an attachment field on the record details page.
✅ SupportedManually delete a single record and empty the recycle bin.
✅ SupportedManually delete records on the current page and empty the recycle bin.
❌ Not supportedSelect the current page in a list, choose Edit, and clear attachment fields in bulk.
❌ Not supportedSelect all data in a list, choose Edit, and clear attachment fields in bulk.
✅ SupportedIn a workflow Update Record node, clear an attachment field for a single record.
✅ SupportedIn a workflow Update Record node, clear an attachment field for multiple records.
✅ SupportedUpdate an attachment through the API with an Update Record node, choosing to overwrite data and remove the old attachment.
❌ Not supportedDelete a single record through the API.
❌ Not supportedDelete multiple records through the API.
❌ Not supportedManually delete all records and empty the recycle bin.
❌ Not supportedDelete a single record in a workflow without moving it to the recycle bin.
❌ Not supportedDelete multiple records in a workflow without moving them to the recycle bin.
❌ Not supportedDelete an entire worksheet directly.
❌ Not supportedDelete 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.