You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/tutorials/chat-interop/includes/meeting-interop-features-file-attachment-csharp.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,32 @@
1
1
---
2
-
title: Tutorial - Enable File Attachment Support
2
+
title: Tutorial - Enable file attachment support
3
3
author: jpeng-ms
4
4
ms.author: jopeng
5
5
ms.date: 04/10/2024
6
6
ms.topic: include
7
7
ms.service: azure-communication-services
8
8
---
9
9
10
-
This tutorial describes how to enable file attachment support using the Azure Communication Services Chat SDK for C#.
10
+
This tutorial describes how to enable file attachment support by using the Azure Communication Services Chat SDK for C#.
11
11
12
-
## Sample code
13
-
Find the finalized code for this tutorial at [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/ChatTeamsInteropQuickStart).
12
+
In this tutorial, you learn how to:
13
+
14
+
- Handle file attachments.
15
+
- Handle image attachments.
14
16
15
-
## Prerequisites
17
+
## Prerequisites
16
18
17
-
* Complete the quickstart [Join your chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md).
18
-
* Create an Azure Communication Services resource as described in [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md). You need to **record your connection string** for this tutorial.
19
-
* Set up a Teams meeting using your business account and have the meeting URL ready.
20
-
* Download the Chat SDK for C# (@azure/communication-chat) 1.3.0 or the latest. See [Azure Communication Chat client library](https://www.nuget.org/packages/Azure.Communication.Chat).
19
+
* Review the quickstart [Join your Chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md).
20
+
* Create an Azure Communication Services resource as described in [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md). You need to *record your connection string* for this tutorial.
21
+
* Set up a Teams meeting by using your business account and have the meeting URL ready.
22
+
* Download the Chat SDK for C# (@azure/communication-chat) 1.3.0 or the latest. For more information, see [Azure Communication Chat client library](https://www.nuget.org/packages/Azure.Communication.Chat).
23
+
24
+
## Sample code
25
+
Find the finalized code for this tutorial at [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/ChatTeamsInteropQuickStart).
21
26
22
27
## Handle file attachments
23
28
24
-
The Chat SDK for C# returns a `ChatAttachmentType` of `file` for regular file attachments and `image` for inline images.
29
+
The Chat SDK for C# returns a `ChatAttachmentType`property of `file` for regular file attachments and `image` for inline images.
For example, the following JSON shows what `ChatAttachment` might look like for an image attachment and a file attachment when receiving requests from the server side:
45
+
For example, the following JSON shows what `ChatAttachment` might look like for an image attachment and a file attachment when you receive requests from the server side:
41
46
42
47
```json
43
48
"attachments": [
@@ -57,7 +62,7 @@ For example, the following JSON shows what `ChatAttachment` might look like for
57
62
]
58
63
```
59
64
60
-
Now let's go back to the event handler we created in previous [quickstart](../../../quickstarts/chat/meeting-interop.md) and add some extra logic to handle attachments with `ChatAttachmentType` of `file`:
65
+
Now go back to the event handler you created in the previous [quickstart](../../../quickstarts/chat/meeting-interop.md) and add some extra logic to handle attachments with the `ChatAttachmentType`property of `file`:
61
66
62
67
```csharp
63
68
@@ -87,19 +92,19 @@ await foreach (ChatMessage message in allMessages)
87
92
88
93
```
89
94
90
-
Specifically, for each file attachment, we get the `previewUrl` and construct a list of URLs in the `for loop`. Then we embed the string along with the chat message content.
95
+
Specifically, for each file attachment, you get the `previewUrl`property and construct a list of URLs in the `for loop`. Then you embed the string along with the Chat message content.
91
96
92
97
## Handle image attachments
93
98
94
-
You need to handle image attachments differently than standard `file` attachments. Image attachments have the `ChatAttachmentType` of `image`, which requires the communication token to retrieve either the preview or full-size images.
99
+
You need to handle image attachments differently than standard `file` attachments. Image attachments have the `ChatAttachmentType`property of `image`, which requires the communication token to retrieve either the preview or full-size images.
95
100
96
-
Before continuing, complete the [Enabling inline image support](../meeting-interop-features-inline-image.md) tutorial. To identity image attachments, we need to find out if the message content contains the same image ID from the attachments.
101
+
Before you continue, finish the [Enable inline image support](../meeting-interop-features-inline-image.md) tutorial. To identity image attachments, you need to find out if the message content contains the same image ID from the attachments.
Copy file name to clipboardExpand all lines: articles/communication-services/tutorials/chat-interop/includes/meeting-interop-features-file-attachment-javascript.md
+39-40Lines changed: 39 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
---
2
-
title: Tutorial - Enable File Attachment Support
2
+
title: Tutorial - Enable file attachment support
3
3
author: jpeng-ms
4
4
ms.author: jopeng
5
5
ms.date: 05/26/2023
6
6
ms.topic: include
7
7
ms.service: azure-communication-services
8
8
---
9
9
10
-
This tutorial describes how to enable file attachment support using the Azure Communication Services Chat SDK for JavaScript.
10
+
This tutorial describes how to enable file attachment support by using the Azure Communication Services Chat SDK for JavaScript.
11
11
12
12
## Sample code
13
13
Find the finalized code of this tutorial on [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/join-chat-to-teams-meeting).
14
14
15
-
## Prerequisites
15
+
## Prerequisites
16
16
17
-
*You've gone through the quickstart -[Join your chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md).
18
-
* Create an Azure Communication Services resource. For details, see [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md). You need to **record your connection string** for this tutorial.
19
-
*You've set up a Teams meeting using your business account and have the meeting URL ready.
20
-
*You're using the Chat SDK for JavaScript (@azure/communication-chat) 1.5.0 or the latest. See [here](https://www.npmjs.com/package/@azure/communication-chat).
17
+
*Review the quickstart [Join your Chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md).
18
+
* Create an Azure Communication Services resource. For more information, see [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md). You need to *record your connection string* for this tutorial.
19
+
*Set up a Teams meeting by using your business account and have the meeting URL ready.
20
+
*Use the Chat SDK for JavaScript (@azure/communication-chat) 1.5.0 or the latest. For more information, see [Azure Communication Chat client library for JavaScript](https://www.npmjs.com/package/@azure/communication-chat).
21
21
22
22
## Goals
23
23
@@ -26,7 +26,7 @@ Find the finalized code of this tutorial on [GitHub](https://github.com/Azure-Sa
26
26
27
27
## Handle file attachments
28
28
29
-
The Chat SDK for JavaScript returns a `ChatAttachmentType` of `file` for regular file attachments and `image` for message-inlined images.
29
+
The Chat SDK for JavaScript returns a `ChatAttachmentType`property of `file` for regular file attachments and `image` for message-inlined images.
@@ -80,12 +80,12 @@ For example, the following JSON shows what `ChatAttachment` might look like for
80
80
]
81
81
```
82
82
83
-
Now let's go back to event handler we created in [Quickstart: Join your chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md) and add some extra logic to handle attachments with `attachmentType` of `file`:
83
+
Now let's go back to the event handler you created in [Quickstart: Join your Chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md) and add some extra logic to handle attachments with the `attachmentType`property of `file`:
84
84
85
85
```js
86
86
chatClient.on("chatMessageReceived", (e) => {
87
87
console.log("Notification chatMessageReceived!");
88
-
//check whether the notification is intended for the current thread
88
+
//Check whether the notification is intended for the current thread
89
89
if (threadIdInput.value!=e.threadId) {
90
90
return;
91
91
}
@@ -101,7 +101,7 @@ async function renderReceivedMessage(event) {
@@ -124,10 +124,10 @@ function renderFileAttachments(attachment) {
124
124
125
125
```
126
126
127
-
Let's make sure we add some CSS for the attachment card:
127
+
Make sure you add some CSS for the attachment card:
128
128
129
129
```css
130
-
/*let's make chat popup scrollable */
130
+
/*Let's make the chat popup scrollable */
131
131
.chat-popup {
132
132
133
133
...
@@ -193,11 +193,11 @@ Let's make sure we add some CSS for the attachment card:
193
193
194
194
```
195
195
196
-
That's all we need for handling file attachments. Next let's run the code.
196
+
That's all you need for handling file attachments. Next, let's run the code.
197
197
198
-
## Run the code
198
+
## Run the code
199
199
200
-
For Webpack, you can use the `webpack-dev-server` to build and run your app. Run the following command to bundle your application host on a local webserver:
200
+
For Webpack, you can use the `webpack-dev-server`property to build and run your app. Run the following command to bundle your application host on a local web server:
1. Open your browser and navigate to `http://localhost:8080/`. Enter the meeting URL and the thread ID.
214
+
1. Open your browser and go to `http://localhost:8080/`. Enter the meeting URL and the thread ID.
215
215
216
-
2. Now let's send some file attachments from Teams client like this:
216
+
1. Send some file attachments from the Teams client.
217
217
218
-
:::image type="content" source="./media/meeting-interop-features-file-attachment-1.png" alt-text="A screenshot of Teams client showing a sent message with three file attachments.":::
218
+
:::image type="content" source="./media/meeting-interop-features-file-attachment-1.png" alt-text="Screenshot that shows the Teams client with a sent message with three file attachments.":::
219
219
220
-
3. Then you should see the new message being rendered along with file attachments:
221
-
222
-
:::image type="content" source="./media/meeting-interop-features-file-attachment-2.png" alt-text="A screenshot of sample app showing a received incoming message with three file attachments.":::
220
+
1. You should see the new message being rendered along with file attachments.
223
221
222
+
:::image type="content" source="./media/meeting-interop-features-file-attachment-2.png" alt-text="Screenshot that shows a sample app with a received incoming message with three file attachments.":::
224
223
225
224
## Handle image attachments
226
225
227
-
Image attachments need to be treated differently than standard `file` attachments. Image attachments have the `attachmentType` of `image`, which requires the communication token to retrieve either the preview or full-size images.
226
+
Image attachments need to be treated differently than standard `file` attachments. Image attachments have the `attachmentType`property of `image`, which requires the communication token to retrieve either the preview or full-size images.
228
227
229
-
Before continuing, complete the tutorial that demonstrates [how to enable inline image support in your chat app](../meeting-interop-features-inline-image.md). This tutorial describes how to fetch images that require a communication token in the request header. Upon receiving the image blob, we need to create an `ObjectUrl` that points to this blob. Then we inject this URL into the `src` attribute of each inline image.
228
+
Before you continue, complete the tutorial that demonstrates [how to enable inline image support in your Chat app](../meeting-interop-features-inline-image.md). This tutorial describes how to fetch images that require a communication token in the request header. After you receive the image blob, you need to create an `ObjectUrl`property that points to this blob. Then you inject this URL into the `src` attribute of each inline image.
230
229
231
-
Now you're familiar with how inline images work, and it's easy to render image attachments just like a regular inline image.
230
+
Now that you're familiar with how inline images work, you can render image attachments like a regular inline image.
232
231
233
232
First, inject an `image` tag into message content whenever there's an image attachment:
234
233
@@ -244,18 +243,18 @@ async function renderReceivedMessage(event) {
@@ -264,7 +263,7 @@ function renderImageAttachments(attachment) {
264
263
}
265
264
```
266
265
267
-
Now let's borrow `fetchPreviewImages()` from the [Tutorial: Enable Inline Image Support](../meeting-interop-features-inline-image.md), and use it as is without any changes:
266
+
Now, let's borrow `fetchPreviewImages()` from the [Tutorial: Enable inline image support](../meeting-interop-features-inline-image.md) and use it as is without any changes:
268
267
269
268
```js
270
269
functionfetchPreviewImages(attachments) {
@@ -295,7 +294,8 @@ function fetchPreviewImages(attachments) {
295
294
});
296
295
}
297
296
```
298
-
This function needs a `tokenString` so we need a global copy initialized in `init()` as demonstrated in the following code snippet:
297
+
298
+
This function needs a `tokenString` property, so you need a global copy initialized in `init()`, as shown in the following code snippet:
299
299
300
300
```js
301
301
var tokenString ='';
@@ -314,17 +314,16 @@ async function init() {
314
314
315
315
Now you have image attachment support. Continue to run the code and see it in action.
316
316
317
-
318
317
## Image attachment demo
319
318
320
-
1. Send some image attachments from Teams client like this:
319
+
1. Send some image attachments from the Teams client.
321
320
322
-
:::image type="content" source="./media/meeting-interop-features-file-attachment-3.png" alt-text="A screenshot of Teams client showing a send box with an image attachment uploaded.":::
321
+
:::image type="content" source="./media/meeting-interop-features-file-attachment-3.png" alt-text="Screenshot that shows the Teams client showing a send box with an image attachment uploaded.":::
323
322
324
-
2. Upon sending the image attachment, notice that it becomes an inline image on the Teams client side:
323
+
1. After you send the image attachment, notice that it becomes an inline image on the Teams client side.
325
324
326
-
:::image type="content" source="./media/meeting-interop-features-file-attachment-4.png" alt-text="A screenshot of Teams client showing a message with the image attachment sent to the other participant.":::
325
+
:::image type="content" source="./media/meeting-interop-features-file-attachment-4.png" alt-text="Screenshot that shows the Teams client showing a message with the image attachment sent to the other participant.":::
327
326
328
-
3. Return to the sample app and make sure the same image is rendered:
327
+
1. Return to the sample app and make sure the same image is rendered.
329
328
330
-
:::image type="content" source="./media/meeting-interop-features-file-attachment-5.png" alt-text="A screenshot of sample app showing an incoming message with one inline image rendered.":::
329
+
:::image type="content" source="./media/meeting-interop-features-file-attachment-5.png" alt-text="Screenshot that shows a sample app showing an incoming message with one inline image rendered.":::
0 commit comments