PubNub allows you to share videos, images, or documents of up to 5 MB with the use of Files feature. Log in to your admin account and go to key set configuration page to enable it.
Sending a file is very similar to publishing a message; you need to specify the channel and provide the actual file to send. Additionally, you can include text to use as a caption for the file.
// in Node.js
import fs from 'fs';
const myFile = fs.readFileSync('./picture.jpg');
const result = await pubnub.sendFile({
channel: 'my_channel',
message: 'Here is your picture!',
file: { data: myFile, name: 'picture.jpg', mimeType: 'image/jpeg' },
});
To receive files, a client must add a listener for file messages and be subscribed to a channel the file is being sent to.
To learn more about files, go to:
- https://www.pubnub.com/docs/files
- https://www.pubnub.com/docs/chat/sdks/messages/files
- https://www.pubnub.com/docs/sdks/javascript/api-reference/files
In case of any questions, please reach out to support@pubnub.com.