Skip to content

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.

```java tab=”Android(Java)”
Bitmap activityImage = …; // Load image here
MediaAttachment imageAttachment = MediaAttachment.image(activityImage);

MediaAttachment urlAttachment = MediaAttachment.imageUrl(“https://docs.getsocial.im/images/logo.png”);

```kotlin tab="Android(Kotlin)"
val activityImage : Bitmap = ... // Load image here
val imageAttachment = MediaAttachment.image(activityImage)

val urlAttachment = MediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png")

```objective-c tab=”iOS(Objective-C)”
UIImage *postImage = … ; // Load image here
MediaAttachment *imageAttachment = [GetSocialMediaAttachment image:postImage];

MediaAttachment *urlAttachment = [GetSocialMediaAttachment imageUrl:@”https://docs.getsocial.im/images/logo.png”];

```swift tab="iOS(Swift)"
let postImage: UIImage = ... // Load image here
let imageAttachment = GetSocialMediaAttachment.image(postImage);

let urlAttachment = GetSocialMediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png") 

```csharp tab=”Unity”
Texture2D activityImage = …;// Load image here
var imageAttachment = MediaAttachment.Image(activityImage);

MediaAttachment urlAttachment = MediaAttachment.ImageUrl(“https://docs.getsocial.im/images/logo.png”);

```javascript tab="React Native"
const imageUri = ...;// Set local image Uri
const imageAttachment = MediaAttachment.withLocalImageUri(imageUri);

const urlAttachment = MediaAttachment.withImageUrl('https://docs.getsocial.im/images/logo.png');

Attach GIFs

To attach GIF:

```java tab=”Android(Java)”
byte[] gifBinary = … ; // Load gif as byte array
MediaAttachment gifAttachment = MediaAttachment.video(gifBinary);

```kotlin tab="Android(Kotlin)"
val gifBinary = ... // Load gif as byte array
val gifAttachment = MediaAttachment.video(gifBinary)

```objectivec tab=”iOS(Objective-C)”
NSData *gifBinary = … ; // Load gif as NSData
GetSocialMediaAttachment *gifAttachment = [MediaAttachment video:gifBinary];

```swift tab="iOS(Swift)"
let gifBinary: Data = ... // Load gif as Data
let mediaAttachment = GetSocialMediaAttachment.video(binary)

```javascript tab=”React Native”
const videoUri = …;// Set local video Uri
const mediaAttachment = MediaAttachment.withLocalVideoUri(videoUri);

### Unity
<p>To simplify GIFs capturing on Unity we've created an [open source GIF recording library](/knowledge-base/gif-capture/). It integrates seemlessly with GetSocial SDK, but you can also use it standalone.</p><br/>

```c# hl_lines="20"
...

public GetSocialCapture capture;

...

// start recording if something interesting happens in the game
void RecordAction()
{
    capture.StartCapture();
}

// stop recording
void ActionFinished()
{
    capture.StopCapture();
    // generate gif
    capture.GenerateCapture(gifBinary =>
    {
        var gifAttachment = MediaAttachment.Video(gifBinary);
        // attach attachment to invite or activity post
    });
}

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.

Give us your feedback! Was this article helpful?

😀 🙁