Skip to main content
Complete reference for all media-related Protocol Buffer messages. Media handling consists of two distinct types: Files (uploaded content without context) and Media (attachments with metadata).

UploadFilePart

Upload a part of a file. Request: media.UploadFilePartResponse: ()
upload_id
uint64
required
Client-generated identifier for the upload
part
uint32
required
Part number (for chunked uploads)
data
bytes
required
Raw file data for this part

DownloadFilePart

Download a part of a file. Request: media.DownloadFilePartResponse: media.FilePart
file_ref
FileRef
required
Reference to the file
offset
uint64
required
Byte offset to start reading from
length
uint32
required
Number of bytes to read

FilePart

data
bytes
Raw file data

FileRef

Reference to a file for download operations.
ref
oneof
One of: media_file (MediaFileRef) or chat_photo (ChatPhotoFileRef)

MediaFileRef

file_id
fixed64
Snowflake ID of the file

ChatPhotoFileRef

file_id
fixed64
Snowflake ID of the chat photo file

UploadedFileRef

Reference to an uploaded file.
id
fixed64
Unique identifier for the uploaded file
name
string
Name of the file
part_count
uint32
Number of parts uploaded

MediaRef

Reference to media for use in messages.
ref
oneof
One of: uploaded (MediaRefUploadedFile) or embed (MediaRefEmbed)

MediaRefUploadedFile

file
UploadedFileRef
Reference to the uploaded file
filename
string
Optional filename override
mimetype
string
MIME type of the file
metadata
FileMetadata
File metadata

MediaRefEmbed

url
string
URL of the embedded media

FileMetadata

Metadata describing file type and properties.
metadata
oneof
One of: image (MetadataImage), video (MetadataVideo), audio (MetadataAudio), file (MetadataFile), or custom_emoji (MetadataCustomEmoji)

MetadataImage

width
uint32
Image width in pixels
height
uint32
Image height in pixels
preview
bytes
Optional thumbnail preview data

MetadataVideo

width
uint32
Video width in pixels
height
uint32
Video height in pixels
duration
uint32
Duration in seconds

MetadataAudio

duration
uint32
Duration in seconds

MetadataFile

Empty metadata for generic files.

MetadataCustomEmoji

width
uint32
Emoji width in pixels
height
uint32
Emoji height in pixels
emoji
string
Unicode emoji character
pack
refs.StickerPackRef
Reference to the sticker pack

File

Complete file object.
file_id
fixed64
Snowflake ID of the file
region
uint32
Storage region identifier
size
uint64
File size in bytes
mimetype
string
MIME type
filename
string
Original filename (optional)
metadata
FileMetadata
File metadata

Files

files
File[]
Array of file objects

MediaFile

File attachment in messages.
file
File
The file object

MediaEmbed

Embed attachment in messages.
url
string
URL of the embed
title
string
Title of the embed (optional)
description
string
Description of the embed (optional)

MessageMedia

Media in a message.
media
oneof
One of: file (MediaFile) or embed (MediaEmbed)

Protocol Definition

syntax = "proto3";

/**
 * How media works
 *
 * There are two distinct and separate types:
 * a) a File, which is a file that is uploaded to the server, devoid of context,
 * usage, or metadata.
 * b) Media, the backing type for attachments in messages,
 * which may contain a reference to a File, along with additional metadata.
 *
 */
package tangle.client.media;

import "refs.proto";

// media.uploadFilePart -> ()
message UploadFilePart {
  // The identifier of the uploaded file. Generated by the client.
  uint64 upload_id = 1;
  uint32 part = 2;
  bytes data = 3;
}

// media.downloadFilePart -> media.FilePart
message DownloadFilePart {
  FileRef file_ref = 1;
  uint64 offset = 2;
  uint32 length = 3;
}

message FilePart { bytes data = 3; }

message FileRef {
  message MediaFileRef {
    // @snowflake<File>
    fixed64 file_id = 1;
  }
  message ChatPhotoFileRef {
    // @snowflake<File>
    fixed64 file_id = 1;
  }

  oneof ref {
    MediaFileRef media_file = 1;
    ChatPhotoFileRef chat_photo = 2;
  }
}

message UploadedFileRef {
  fixed64 id = 1;
  string name = 2;
  uint32 part_count = 3;
}

message MediaRef {
  oneof ref {
    MediaRefUploadedFile uploaded = 1;
    MediaRefEmbed embed = 2;
  }
}

message MediaRefUploadedFile {
  UploadedFileRef file = 1;
  optional string filename = 2;
  string mimetype = 3;
  FileMetadata metadata = 4;
}

message MediaRefEmbed {
  string url = 1;
}

// File metadata, used to store information about the file, included with media.
message FileMetadata {
  message MetadataImage {
    uint32 width = 1;
    uint32 height = 2;
    optional bytes preview = 3;
  }
  message MetadataVideo {
    uint32 width = 1;
    uint32 height = 2;
    uint32 duration = 3; // in seconds
  }
  message MetadataAudio {
    uint32 duration = 1; // in seconds
  }
  message MetadataFile {}
  message MetadataCustomEmoji {
    uint32 width = 1;
    uint32 height = 2;
    string emoji = 3;
    refs.StickerPackRef pack = 4;
  }

  oneof metadata {
    MetadataImage image = 1;
    MetadataVideo video = 2;
    MetadataAudio audio = 3;
    MetadataFile file = 4;
    MetadataCustomEmoji custom_emoji = 5;
  }
}

message File {
  // @snowflake<File>
  fixed64 file_id = 1;
  uint32 region = 2;
  uint64 size = 3;
  string mimetype = 4;
  optional string filename = 5;
  FileMetadata metadata = 6;
}

message Files {
  repeated File files = 1;
}

message MediaFile {
  File file = 1;
  // TODO: spoiler, etc
}

message MediaEmbed {
  string url = 1;
  optional string title = 2;
  optional string description = 3;
  // TODO: spoiler, etc
}

// Media in messages
message MessageMedia {
  oneof media {
    MediaFile file = 1;
    MediaEmbed embed = 2;
  }
}

Build docs developers (and LLMs) love