0

What I was doing, converting the whole image to base64 string and sending it as a message. But message sending failed each time. I got maximum payload size is 32 KB for a single PubNub message here. If I compress the image and so that my message size is less than 32 KB, will it be delivered? Is there any other API available from PubNub SDK to upload or streaming a file/image to a channel?

Sauvik Dolui
  • 5,520
  • 3
  • 34
  • 44
  • Basically you actually store the images anywhere (there's a thousand choices, any web server, image upload service - anything). You pass around the **info** instantly with PubNub messaging. You can't send photos, as such, around via messaging (and you wouldn't want to for any reason). – Fattie Mar 04 '17 at 16:29

1 Answers1

2

Encoding images into Base64 string is the right way to send image data to PubNub stream, only if the total size is under 32kb. Otherwise, you get message too large error.

PubNub data stream is for data, not for large payloads such as photos and video streaming, so:

  1. you may just want to publish the image path/url, instead of an encoded image itself. It is the easiest way.

or

  1. you break off the data into multiple parts and send pieces of data separately.
girlie_mac
  • 593
  • 5
  • 7
  • 3
    You are right. Later I found Cloudinary http://cloudinary.com. Now I am uploading image to Cloudinary cloud storage. On completion upload, I am sending the image metadata (url, size, width etc.) with PubNub. When new message arrives from PunNub I am drawing the view according to the image metadata. Image in chat bubble is being downloaded from Cloudinary cloud storage with the url coming from PubNub message. – Sauvik Dolui Apr 29 '15 at 06:52