dillenmeister/Trello.NET

Upload Attachment

Closed this issue · 11 comments

Right now Trello.NET only supports attachment links. Some of the other libs like python based Trolly supports file attachment upload. Can this be added?

Sound like a great addition to Trello.NET. Are you up for it?

Been hammering at it for a bit now. The magic incantation has not arrived =)

OK...Got it working now. Let me know if you want to add it. I did it with raw HttpWebRequest but that should be easy to move to the RestSharp lib.

This is great! I definately want to add it!

Could you send a pull request?

The implementation does not HAVE to use RestSharp. Trello.NET does not expose RestSharp to the outside world and none of the integration tests knows about RestSharp.either.

We can talk here about how the API should look like if you want to do that before sending the pull request.

I did a quick spike and I got it to work using RestSharp! The RestRequest class has a method AddFile which did the job... I will implement the feature now that I know how this works, unless you want to do that pull request.

Go for it. I was planning on sending the pull request this weekend so if
you've already got it then yeah I'd go ahead.

On Thu, Jan 31, 2013 at 7:37 AM, Oskar Dillén notifications@github.comwrote:

I did a quick spike and I got it to work using RestSharp! The RestRequestclass has a method
AddFile which did the job... I will implement the feature now that I know
how this works, unless you want to do that pull request.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-12940530.

http://www.linkedin.com/in/abawcom

@clearly If you could test this feature in your application it would be really helpful!

It's version 0.5.9-beta1 on NuGet (Install-Package TrelloNet -Pre).

There are two ways to upload an attachment, either using a file path:

trello.Cards.AddAttachment(card, new FileAttachment(@"C:\temp\image.jpg", "An image"));

Or an array of bytes:

trello.Cards.AddAttachment(card, new BytesAttachment(File.ReadAllBytes(@"C:\temp\image.jpg"), "An image", "image.jpg"));

Let me know if you find any bugs or if you have any thoughts on the API etc. Thanks!

@clearly Did you have time to look at these changes?

Just tested it and yes it works.

As far as comments on the API in general: Before I switched to Trello I was doing some work with Pivotal (I found Trello to be better). That said, there was a pretty great .Net API for Pivotal. It is a Fluent based library with heavy use of facades and it makes for pretty amazing usage. The project page which has some great examples can be found here => http://ptfluentapi.codeplex.com/

Great! I'll close this issue then.

I love fluent API:s and I have thought a bit about doing it for Trello.NET. As I see it, it's a layer on top of either ITrello or the request classes (the layer below). If you are interested in this and want to spike something out for Trello.NET I'll be happy to collaborate on that.