Media Attachment Guide¶
Media Attachment is a general purpose class used across GetSocial SDK to attach images, videos and GIFs.
Supported Formats and Size Limitations¶
Supported Formats | Size Limitation | |
---|---|---|
Images | jpg, png, webp, cr2, tif, bmp | 20 Mb |
GIFs | gif | 20 Mb |
Videos | mp4, m4v, mkv, webm, mov, avi, wmv, mpg, flv, 3gp | 20 Mb |
If media size is bigger than the size limitation -it is ignored.
Attach Images¶
The image can be attached as a binary file, or as URL reference. Binary files are uploaded to GetSocial backend and optimized to serve back to the SDK.
val activityImage : Bitmap = ... // Load image here
val imageAttachment = MediaAttachment.image(activityImage)
val urlAttachment = MediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png")
let postImage: UIImage = ... // Load image here
let imageAttachment = MediaAttachment.image(postImage);
let urlAttachment = MediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png")
Texture2D postImage = ...; // load image here
var imageAttachment = MediaAttachment.WithImage(postImage);
var urlAttachment = MediaAttachment.WithImageUrl("https://docs.getsocial.im/images/logo.png");
var postImage = ...; // Base64 encoded image
var imageAttachment = MediaAttachment.withBase64Image(postImage);
var urlAttachment = MediaAttachment.withImageUrl('https://docs.getsocial.im/images/logo.png');
const postImage = ...; // Base64 encoded image
const imageAttachment = MediaAttachment.withBase64Image(postImage);
const urlAttachment = MediaAttachment.withImageUrl('https://docs.getsocial.im/images/logo.png');
const postImage = ...; // Base64 encoded image
const imageAttachment = GetSocialSDK.MediaAttachment.withBase64Image(postImage);
const fileImage = ...; // File instance
const fileAttachment = GetSocialSDK.MediaAttachment.withImageFile(fileImage);
const urlAttachment = GetSocialSDK.MediaAttachment.withImageUrl('https://docs.getsocial.im/images/logo.png');
Attach GIFs¶
To attach GIF:
val gifBinary = ... // Load gif as byte array
val gifAttachment = MediaAttachment.video(gifBinary)
let gifBinary: Data = ... // Load gif as Data
let gifAttachment = MediaAttachment.video(binary)
byte[] videoData = ... // load gif as byte[]
var gifAttachment = MediaAttachment.WithVideo(videoData);
var base64Video = ...; // Base64 encoded video
var gifAttachment = MediaAttachment.withBase64Video(base64Video);
const base64Video = .../ Base64 encoded video
const gifAttachment = MediaAttachment.withBase64Video(base64Video);
const base64Video = ... // Base64 encoded video
const gifAttachment = GetSocialSDK.MediaAttachment.withBase64Video(base64Video);
const fileVideo = ... // File video
const gifAttachment = GetSocialSDK.MediaAttachment.withVideoFile(fileVideo);
Attach Videos¶
Video can be attached as a binary file using the same method as for GIFs, or as URL reference. Binary files are uploaded to GetSocial backend and optimized to serve back to the SDK.