The media resource manages files in your workspace's media library. See also Media concepts.
Methods
| Method | What it does |
|---|---|
upload(file, filename?) | Upload a Buffer or Blob |
list(query?) | Paginate the library |
get(id) | Fetch one item |
update(id, metadata) | Update alt, description, tags |
delete(id) | Delete one |
bulkDelete(ids) | Delete many |
Upload
typescript
import { readFileSync } from 'fs'
const item = await socifyr.media.upload(
readFileSync('banner.jpg'),
'banner.jpg',
)
console.log(item.id) // 6a04f715d3d7d93575e65d13
console.log(item.url) // signed S3 URL (1h expiry)
console.log(item.type) // 'image' | 'video' | 'document'
console.log(item.sizeBytes) // 245678List
typescript
const { results, total, page, limit } = await socifyr.media.list({
type: 'image', // optional filter
search: 'banner', // optional full-text on filename
tags: ['campaign-q2'],// optional
limit: 20,
})Update metadata
typescript
await socifyr.media.update(id, {
alt: 'Product banner with logo',
description: 'Used in Q2 campaign',
tags: ['campaign-q2', 'evergreen'],
})Alt text is preserved when the asset is reused — important for accessibility on LinkedIn and Twitter.
Delete
typescript
await socifyr.media.delete(id)
await socifyr.media.bulkDelete([id1, id2, id3])Deleting media doesn't affect already-published posts — those keep their copies on the platforms' servers.
Types
typescript
import type { MediaItem, MediaQuery, MediaMetadata } from '@socifyr/sdk'
interface MediaItem {
id: string
name: string
mimeType: string
sizeBytes: number
url: string
thumbnailUrl?: string
type: 'image' | 'video' | 'document'
alt?: string
description?: string
tags?: string[]
usedInContentCount?: number
createdAt: string
updatedAt?: string
}