Attachment
This topic guides how to operate with attachments within TMT, including: upload, download and delete attachment.
In TMT, an attachment is any file that can be attached to a TMT business object (Test case, Run, Suite, etc.)
A TMT business object always attach the attachments into its body at the following path: Root/Attachments
It is an array of the attachment with definition can be found here:
An attachment must be associated with a document. Otherwise, it will be removed automatically after 2 days.
Upload attachment
Attachments can be uploaded to the server using the upload attachment endpoint
There is no attachment update available. To change attachment create new attachment and un-assign old one.
Month | Savings | Detected Mime Type |
---|---|---|
Json | Attachment | text/plain |
Json | Attachment.json | application/json |
csv | Attachment | text/plain |
csv | Attachment.csv | text/csv |
The table below shows the differences in mime type detection between uploading attachments with and without correct filename. There are differences in mime type detection for MS Word doc and docx files. Based on https://www.askingbox.com/info/mime-types-of-microsoft-office-file-formats, MS Word doc file will have mime type application/msword and MS Word docx file will have mime type application/vnd.openxmlformats-officedocument.wordprocessingml.document.
Attach an attachment
As we mentioned earlier, an attachment must be attached into a document, so that it can be used. This section guide you how to do it.
-
Build TMT attachment object to match Attachment type, using the information extracted from the response from upload attachment endpoint
Example
{
"FileName": "00bdd931-7284-4ca5-97ac-ff2d06d09640_thumbnail_big.jpeg",
"File": {
"content": null,
"attachment_id": "703b9da8-edb0-434b-9789-7f755957d7ed",
"internal_filename": "1730108285874-f2567f07-6d09-4d7f-8aa5-cd27f2c4c4f0.jpeg",
"original_filename": "00bdd931-7284-4ca5-97ac-ff2d06d09640_thumbnail_big.jpeg",
"size": 35169,
"mime_type": "image/png"
},
"CreatedAt": "2024-10-28T09:38:06",
"UploadOn": "2024-10-28",
"OriginalFileName": "00bdd931-7284-4ca5-97ac-ff2d06d09640_thumbnail_big.jpeg",
"UploadBy": "tmtdev",
"Referenced": false,
"CopyNumber": 0,
"ThumbnailId": "f1a218ff-e70b-4e84-9562-00d7651f9818"
}
-
Add this Attach object into Attachments array object of the document, then update the document (i.e. use MODIFY_DOCUMENT operation for saving a Test suite) The group Attachment must be located under the path Root/Attachment as we defined in above pathToField value
See the update a test suite payload that containing an attachment for reference
Retrieve attachment
An attachment can be downloaded via 2 operations: LOAD_THUMBNAIL_URL and LOAD_ATTACHMENT_URL These returns the attachment urls, where you can make a call to download the attachment, but please be noticed that the url for attachment will be expired after 5 minutes due to the security purpose
Delete attachment
There is no API to delete attachments from the TMT system directly. The attachments are marked for deletion if the TMT object has unassigned attachment from its references. Then TMT will delete it in background automatically.
You can easily mark an attachment for deletion by simply removing the element from Attachments section of the desired document.