diff --git a/Changelog.md b/Changelog.md
index b5bf8d1..9ffa643 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,13 @@
# Changelog
*Below is the version history of [TrelloDotNet](https://github.com/rwjdk/TrelloDotNet) (An wrapper of the Trello API)*
+## 1.11.3 (3rd of November 2024)
+#### TrelloClient
+- Added [GetAttachmentOnCardAsync](https://github.com/rwjdk/TrelloDotNet/wiki/GetAttachmentOnCardAsync)
+- Added [DownloadAttachment](https://github.com/rwjdk/TrelloDotNet/wiki/DownloadAttachment) [Via Ids or URL]
+
+
+
## 1.11.2 (9th of October 2024)
#### TrelloClient
- `GetBoardOptions` now have Filter options (All, Open, Closed or Starred boards)
diff --git a/src/TrelloDotNet/Control/ApiRequestController.cs b/src/TrelloDotNet/Control/ApiRequestController.cs
index 1f7e909..cf0ad40 100644
--- a/src/TrelloDotNet/Control/ApiRequestController.cs
+++ b/src/TrelloDotNet/Control/ApiRequestController.cs
@@ -18,6 +18,8 @@ internal class ApiRequestController
private readonly string _token;
private readonly TrelloClient _client;
+ internal HttpClient HttpClient => _httpClient;
+
internal ApiRequestController(HttpClient httpClient, string apiKey, string token, TrelloClient client)
{
_httpClient = httpClient;
@@ -29,6 +31,8 @@ internal ApiRequestController(HttpClient httpClient, string apiKey, string token
public string Token => _token;
+ public string ApiKey => _apiKey;
+
internal async Task Get(string suffix, CancellationToken cancellationToken, params QueryParameter[] parameters)
{
string json = await Get(suffix, cancellationToken, 0, parameters);
diff --git a/src/TrelloDotNet/TrelloClient.Attachments.cs b/src/TrelloDotNet/TrelloClient.Attachments.cs
index 337a6dd..4638aa9 100644
--- a/src/TrelloDotNet/TrelloClient.Attachments.cs
+++ b/src/TrelloDotNet/TrelloClient.Attachments.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using TrelloDotNet.Control;
@@ -31,6 +33,17 @@ public async Task DeleteAttachmentOnCardAsync(string cardId, string attachmentId
await _apiRequestController.Delete(GetUrlBuilder.GetAttachmentOnCard(cardId, attachmentId), cancellationToken, 0);
}
+ ///
+ /// Get an Attachments on a card
+ ///
+ /// Id of the Card
+ /// Id of Attachment
+ /// Cancellation Token
+ public async Task GetAttachmentOnCardAsync(string cardId, string attachmentId, CancellationToken cancellationToken = default)
+ {
+ return await _apiRequestController.Get(GetUrlBuilder.GetAttachmentOnCard(cardId, attachmentId), cancellationToken);
+ }
+
///
/// Add an Attachment to a Card
///
@@ -88,5 +101,37 @@ public async Task AddAttachmentToCardAsync(string cardId, Attachment
return await _apiRequestController.PostWithAttachmentFileUpload($"{UrlPaths.Cards}/{cardId}/attachments", attachmentFileUpload, cancellationToken, parameters.ToArray());
}
+
+ ///
+ /// Download an Attachment
+ ///
+ /// Id of the Card
+ /// Id of Attachment
+ /// Cancellation Token
+ ///
+ public async Task DownloadAttachment(string cardId, string attachmentId, CancellationToken cancellationToken = default)
+ {
+ Attachment attachment = await GetAttachmentOnCardAsync(cardId, attachmentId, cancellationToken);
+ return await DownloadAttachment(attachment.Url, cancellationToken);
+ }
+
+ ///
+ /// Download an Attachment
+ ///
+ /// URL of the attachment
+ /// Cancellation Token
+ ///
+ public async Task DownloadAttachment(string url, CancellationToken cancellationToken = default)
+ {
+ try
+ {
+ _apiRequestController.HttpClient.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse($"OAuth oauth_consumer_key=\"{_apiRequestController.ApiKey}\", oauth_token=\"{_apiRequestController.Token}\"");
+ return await _apiRequestController.HttpClient.GetStreamAsync(url);
+ }
+ finally
+ {
+ _apiRequestController.HttpClient.DefaultRequestHeaders.Authorization = null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/TrelloDotNet/TrelloDotNet.csproj b/src/TrelloDotNet/TrelloDotNet.csproj
index d3e0d98..656f2ad 100644
--- a/src/TrelloDotNet/TrelloDotNet.csproj
+++ b/src/TrelloDotNet/TrelloDotNet.csproj
@@ -13,7 +13,7 @@
https://github.com/rwjdk/TrelloDotNet/wiki
trello.png
trello api rest .NET dotNet crud wrapper webhook automation
- 1.11.2
+ 1.11.3
RWJDK
true
true