Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Adding attachments to a Bug

Hi all,
a basic question: how to add several attachments to a bug?
I'm able to create attachments from uploaded files, but then I'm a bit confused. What I want to do is to attach two files and a comment to a given bug.
Ciao
Marco Botton Send private email
Wednesday, May 20, 2009
 
 
Currently it's not possible.  I have a case open for this slated to be done for the next release.  Sorry for the delay!
David Fullerton Send private email
Wednesday, May 20, 2009
 
 
Thank you David
Marco Botton Send private email
Thursday, May 21, 2009
 
 
This has been implemented and will be included in the next release.  The code looks like this:


bug.Commit("Added new attachment", new CAttachment[] { attachment });
David Fullerton Send private email
Thursday, May 21, 2009
 
 
It seems it's perfect, thank you.
I have some more questions about attachments, and it's the right time to ask. ;-)

I wrote some code to get all attachments of a given bug. Can this simple query be included in your API? It's quite useful for plugin developers.

Then, I need to download the attachments of a certain mime type. How to know the mime type? Currently, I check the sFileName field of CAttachment.

And what about the download link? Is there an API for it?
I would like not to hard-code an URL like this: http://balsamiq9653/FogBugz/default.asp?pg=pgDownload&pgType=pgFile&ixBugEvent=6&ixAttachment=3&sTicket=&sFileName=Dialog.png

Ciao and thanks
Marco
Marco Botton Send private email
Tuesday, May 26, 2009
 
 
Hi Marco-

No, there is not an API for getting the download link for an attachment right now. It might be preferable to use IPluginBinaryPageDisplay to get the file; the FilterExport plugin has a good example of how to do this. Does that sound reasonable? It's a little bit less convenient, but it isolates you from any changes we might make to the way pgDownload works.

I will open a case to include a method to get all attachments of a Bug.

Thanks!
Brett
Brett Kiefer Send private email
Tuesday, May 26, 2009
 
 
Hi Marco-
On second thought, I can see why you would want to provide an attachment download link, so I will add a feature request for that.
Thanks!
Brett
Brett Kiefer Send private email
Tuesday, May 26, 2009
 
 
To get all the attachments for a Bug, use CAttachmentQuery:

CAttachmentQuery query = api.Attachment.NewAttachmentQuery();
query.AddWhere("ixBug = @ixBug");
query.SetParamInt("ixBug", ixBug);
CAttachment[] rg = query.List();
David Fullerton Send private email
Tuesday, June 2, 2009
 
 
I have to write Bug.ixBug in the addWhere statement, otherwise it doesn't work.
Marco Botton Send private email
Friday, June 5, 2009
 
 
Ah, sorry, yes, because we JOIN Bug to Attachment.  You could also use "Attachment.ixBug".
David Fullerton Send private email
Friday, June 5, 2009
 
 
CAttachment now exposes a DownloadUrl property.  This will go out with the next release.
David Fullerton Send private email
Thursday, June 11, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz