Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 41a0f6c

Browse files
committed
Make UploadAttachment using stream public.
1 parent 1f636fb commit 41a0f6c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/SymphonyOSS.RestApiClient/Api/AgentApi/AttachmentsApi.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,14 @@ public AttachmentInfo UploadAttachment(string sid, string file)
7272
}
7373

7474
/// <summary>
75-
/// Downloads an attachment from a message.
75+
/// Uploads an attachment to an existing stream. After the attachment is uploaded it can
76+
/// be used on a message in that stream.
7677
/// </summary>
7778
/// <param name="sid">Stream ID.</param>
78-
/// <param name="messageId">The ID of the message containing the attachment.</param>
79-
/// <param name="fileId">Attachment ID.</param>
80-
/// <returns>The contents of the attached file.</returns>
81-
public byte[] DownloadAttachment(string sid, string messageId, string fileId)
82-
{
83-
var base64Bytes = _apiExecutor.Execute(_attachmentsApi.V1StreamSidAttachmentGet, sid, fileId, messageId, _authTokens.SessionToken, _authTokens.KeyManagerToken);
84-
var base64String = System.Text.Encoding.UTF8.GetString(base64Bytes);
85-
return Convert.FromBase64String(base64String);
86-
}
87-
88-
private AttachmentInfo UploadAttachment(string sid, string filename, Stream file)
79+
/// <param name="filename">The filename.</param>
80+
/// <param name="file">The stream of the file to upload as an attachment.</param>
81+
/// <returns>Attachment info.</returns>
82+
public AttachmentInfo UploadAttachment(string sid, string filename, Stream file)
8983
{
9084
var request = new RestRequest("v1/stream/" + sid + "/attachment/create", Method.POST);
9185
request.AddHeader("sessionToken", _authTokens.SessionToken);
@@ -96,5 +90,19 @@ private AttachmentInfo UploadAttachment(string sid, string filename, Stream file
9690
var response = apiClient.RestClient.Execute(request);
9791
return (AttachmentInfo)apiClient.Deserialize(response, typeof(AttachmentInfo));
9892
}
93+
94+
/// <summary>
95+
/// Downloads an attachment from a message.
96+
/// </summary>
97+
/// <param name="sid">Stream ID.</param>
98+
/// <param name="messageId">The ID of the message containing the attachment.</param>
99+
/// <param name="fileId">Attachment ID.</param>
100+
/// <returns>The contents of the attached file.</returns>
101+
public byte[] DownloadAttachment(string sid, string messageId, string fileId)
102+
{
103+
var base64Bytes = _apiExecutor.Execute(_attachmentsApi.V1StreamSidAttachmentGet, sid, fileId, messageId, _authTokens.SessionToken, _authTokens.KeyManagerToken);
104+
var base64String = System.Text.Encoding.UTF8.GetString(base64Bytes);
105+
return Convert.FromBase64String(base64String);
106+
}
99107
}
100108
}

0 commit comments

Comments
 (0)