Skip to content

Commit ebd1f1d

Browse files
Merge pull request #851 from GetStream/develop
Docs update
2 parents fedc792 + bf170cd commit ebd1f1d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docusaurus/docs/reactnative/guides/message_input_customization.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,48 @@ const StreamButton = () => {
183183
/>
184184
```
185185

186+
## Storing image and file attachment to custom CDN
187+
188+
When you select an image or file from image picker or file picker, it gets uploaded to Stream's CDN by default.
189+
But you can choose to upload attachments to your own CDN using following two props on Channel component:
190+
191+
- [`doImageUploadRequest`](../core-components/channel.mdx#doimageuploadrequest): For images picked from image picker
192+
- [`doDocUploadRequest`](../core-components/channel.mdx#dodocuploadrequest): For files picked from file picker
193+
194+
```tsx
195+
<Channel
196+
doDocUploadRequest={(file, channel) =>
197+
chatClient?.sendFile(
198+
`${channel._channelURL()}/file`, // replace this with your own cdn url
199+
file.uri,
200+
'name_for_file',
201+
)
202+
}
203+
doImageUploadRequest={(file, channel) =>
204+
chatClient?.sendFile(
205+
`https://customcdnurl.com`, // replace this with your own cdn url
206+
file.uri,
207+
'name_for_file',
208+
)
209+
}
210+
/>
211+
```
212+
213+
:::note
214+
215+
Usage of `chatClient?.sendFile` is optional in above examples. You may choose to use any HTTP client for uploading the file.
216+
But make sure to return a promise that is resolved to an object with the key `file` that is the url of the uploaded file.
217+
218+
For example:
219+
220+
```tsx
221+
{
222+
file: 'https://us-east.stream-io-cdn.com/62344/images/a4f988f5-6a9c-47b0-aab9-7a27b74d7515.60D6041A-D012-4721-B794-19267B8F352B.jpg'
223+
}
224+
```
225+
226+
:::
227+
186228
## Disabling File Uploads or Image Uploads
187229

188230
There are three ways to disable file or image uploads from RN app:

0 commit comments

Comments
 (0)