attachment upload to DISK into directories by ticket number

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
michaelgeorge
Posts: 4
Joined: 17 Mar 2023, 18:41

attachment upload to DISK into directories by ticket number

Post by michaelgeorge »

I am testing attachment uploads in our MantisBT installation and putting those uploads onto an NFS file system.

Since this is open-source software and our attachments could be needed for audits for up to three years, I have been asked what we would do if something happened and MantisBT was not able to properly associate uploaded documents to our changes for some reason. Currently, MantisBT creates separate directories for each Project, but then uses a unique file name across all the tickets. I am not able to determine how I can determine the bug/ticket number from the file name.

As such, we are hesitant to trust MantisBT to handle all of our Compliance documents.

Am I overlooking a setting or some mapping method that would allow tracing from the file names to the associated ticket?
cas
Posts: 1768
Joined: 11 Mar 2006, 16:08
Contact:

Re: attachment upload to DISK into directories by ticket number

Post by cas »

You can do that with a simple query using a tool like phpmyadmin.
I you have issues with that, I canhelp you to creatde such a query
michaelgeorge
Posts: 4
Joined: 17 Mar 2023, 18:41

Re: attachment upload to DISK into directories by ticket number

Post by michaelgeorge »

We have returned to testing on this issue. In our test-instance the attachments are now going into the g_absolute_path_default_upload_folder directory, not into subdirectories by Project.

cas, I believe you are saying that in order to map uploads to tickets, we would run a (read-only) query against the database in order to gather that information. Is that correct?

We did figure that with a bit of investigation we could do it that way. I am hoping for something more straightforward. Apparently, though, the location and naming of the attachment files does not separate by Project or ticket number.
atrol
Site Admin
Posts: 8589
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: attachment upload to DISK into directories by ticket number

Post by atrol »

michaelgeorge wrote: 13 Oct 2026, 14:16 cas, I believe you are saying that in order to map uploads to tickets, we would run a (read-only) query against the database in order to gather that information. Is that correct?
Sad news concerning Cas, see viewtopic.php?t=33894
Please use Search before posting and read the Manual
dregad
Developer
Posts: 105
Joined: 26 Jul 2010, 14:24

Re: attachment upload to DISK into directories by ticket number

Post by dregad »

the location and naming of the attachment files does not separate by Project or ticket number
Separation by ticket number is not possible out of the box, but you can easily separate storage of attachments per project, by setting the Upload File Path as appropriate in the manage project page.

You cannot determine the ticket number from the file name (it's just a hash, i.e. a random sequence of letters and numbers. This is by design.

The only way to get the association, as mentioned by cas, is to look it up in the database (bug_file table), e.g. (adjust table prefix/suffix as needed)

Code: Select all

SELECT p.name, bug_id, f.id "attachment id", filename, diskfile, folder
FROM mantis_bug_file_table f
JOIN mantis_bug_table b ON f.bug_id = b.id
JOIN mantis_project_table p ON b.project_id = p.id
Note that the folder column may not reflect the actual file location; this can happen if the configuration changed after the file was uploaded.

It should not be too hard to write a small script that you could run as needed, that would copy the attachments to an audit-friendly directory structure based on issue id.
Post Reply