feat(ui-flow): attachment download IPC for save-to-disk

Handle request-attachment-download using readAttachmentBytesWithSource
for any mime type and reply with base64 payload or error.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 23:55:24 -04:00
co-authored by Cursor
parent 47ec7494a7
commit 480fb7cb12
+23
View File
@@ -1392,6 +1392,29 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
})
return true
}
if (t === 'request-attachment-download') {
const attachmentId = msg.attachmentId
try {
const row = await platform.attachments?.get(attachmentId)
if (!row) throw new Error('attachment not found')
const { buf, source } = await platform.readAttachmentBytesWithSource(attachmentId)
send({
type: 'attachment-download',
attachmentId: row.id,
filename: row.filename || 'download',
mimeType: row.mimeType || 'application/octet-stream',
dataBase64: b4a.toString(buf, 'base64'),
fetchSource: source
})
} catch (err) {
send({
type: 'attachment-download-error',
attachmentId,
message: err?.message || String(err)
})
}
return true
}
if (t === 'upsert-guild-emoji') {
await platform.upsertGuildEmoji({
name: msg.name,