@@ -72,20 +72,14 @@ public AttachmentInfo UploadAttachment(string sid, string file)
72
72
}
73
73
74
74
/// <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.
76
77
/// </summary>
77
78
/// <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 )
89
83
{
90
84
var request = new RestRequest ( "v1/stream/" + sid + "/attachment/create" , Method . POST ) ;
91
85
request . AddHeader ( "sessionToken" , _authTokens . SessionToken ) ;
@@ -96,5 +90,19 @@ private AttachmentInfo UploadAttachment(string sid, string filename, Stream file
96
90
var response = apiClient . RestClient . Execute ( request ) ;
97
91
return ( AttachmentInfo ) apiClient . Deserialize ( response , typeof ( AttachmentInfo ) ) ;
98
92
}
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
+ }
99
107
}
100
108
}
0 commit comments