Skip to content
DunSocial Docs

Media

Upload images and videos without managing signed URLs.

media.upload hides the three-step API: request an upload URL, PUT the bytes, then complete the gallery row.

const asset = await dun.media.upload({
file: new Uint8Array(await file.arrayBuffer()),
filename: 'cover.png',
mimeType: 'image/png',
altText: 'Release cover'
});

await dun.posts.schedule({
content: 'New cover.',
socialAccountIds: ['acc_x'],
mediaIds: [asset.id],
scheduledAt: new Date(Date.now() + 3600_000)
});

Accepted input: Uint8Array, ArrayBuffer, or Blob. Images max 8MB (image/jpeg, image/png, image/gif, image/webp). Video max 512MB (video/mp4, video/quicktime, video/webm).

A failed PUT after the URL is issued does not create a gallery row. If the presign expired, call upload() again.

List and delete use the same gallery as the app: media.list(), media.get(id), media.delete(id).