Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Uploading files in custom plugin

I'm trying to figure out how to upload files (like images) via custom forms and how to store those in a custom database.  Are there any examples? Or at least point me to the api classes that I would need. I can't seem to find anything.

thanks
tracstarr Send private email
Monday, January 4, 2010
 
 
Hi Tracstarr-
The API you want to get the file from the request is CPluginRequest.GetFile - http://www.fogcreek.com/fogbugz/library/70/html/E96D3E72.htm
The Workflow plugin does this to get a custom category image. You can see this in Plugins/Examples/Workflow/CCategoryEditor.was, the EditCategoryData and LoadCategoryFromRequest functions.
Thanks!
Brett
Brett Kiefer Send private email
Monday, January 4, 2010
 
 
thanks. I totally didn't see that in that example.
tracstarr Send private email
Monday, January 4, 2010
 
 
Perfect. All seems to work great.

One question though. How can we delete an attachment? I found a method through the CBug class, but it doesn't apply in my case.

Will I just have to call a query directly to delete that row?
tracstarr Send private email
Monday, January 4, 2010
 
 
It doesn't apply because the attachment is not attached to a Bug?
Brett Kiefer Send private email
Tuesday, January 5, 2010
 
 
correct. the file i'm uploading is similar to uploading a custom logo to the site, but i'm applying this to my custom entities. So right now since the only way i know to get the file automatically adds it to attachments table, i have a fk from my entity table to the attachment ix. But if my entities are removed, i also want to remove the associated attachment.
tracstarr Send private email
Tuesday, January 5, 2010
 
 
If you're putting it in the Attachment table but not attaching it to a bug, then yes, I would say just delete the rows by query.

It sounds like you ended up not using CPluginPostFile? Or you stored it in Attachment anyway?
Brett Kiefer Send private email
Wednesday, January 6, 2010
 
 
wow, some days i seem to only read what I want to read. I didn't notice the second method to get the file. I only looked in the example, which uses the Request.GetFile, which automatically uses the attachment table. Must look into the other method. Thanks. :S
tracstarr Send private email
Wednesday, January 6, 2010
 
 
wait... is this not just the same thing?
tracstarr Send private email
Wednesday, January 6, 2010
 
 
so it's way too early for me right now. Ignore my last two comments. I missed the fact that I'm actually posting it to the attachment table myself. A case of just blindly following an example.
tracstarr Send private email
Wednesday, January 6, 2010
 
 

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

Other recent topics Other recent topics
 
Powered by FogBugz