New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

matrix-media

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matrix-media

Allows uploading files to matrix.org homeserver through media api.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

MediaClient

MediaClient is a simple JavaScript class for uploading and downloading media files to/from a Matrix homeserver.

Installation

npm install matrix-media

(Replace with your actual package name or usage)

Usage

const MediaClient = require('matrix-media');

const client = new MediaClient({ token: 'YOUR_ACCESS_TOKEN' });

// Upload a file buffer
const mxcUri = await client.upload(fileBuffer, 'filename.ext');
// mxcUri example: "mxc://matrix.org/abcdefg"

// Download a file from Matrix (returns Uint8Array)
const fileData = await client.downloadBuffer(mxcUri);

API

constructor({ fetch = globalThis.fetch, token })

  • fetch — Optional: custom fetch implementation (default: global fetch)
  • token — Required: Matrix access token for authorization

async upload(buffer, filename = "upload.bin") : Promise

  • buffer — Buffer | Uint8Array | ArrayBuffer — File content to upload
  • filename — string (optional) — Filename to use on upload (default: "upload.bin")

Returns a Promise that resolves to the Matrix content URI (mxc://...). The max upload size is ~50MB.

async downloadBuffer(mxcOrMediaUrl, timeout = 5000) : Promise

  • mxcOrMediaUrl — string — Matrix content URI (mxc://...) or direct download URL
  • timeout — number (optional) — Timeout in milliseconds (default: 5000)

Returns a Promise resolving to the file data as a Uint8Array.

Keywords

matrix

FAQs

Package last updated on 06 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts