mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:44:32 +00:00
refactor(media): share outbound attachment resolver
This commit is contained in:
16
src/media/outbound-attachment.ts
Normal file
16
src/media/outbound-attachment.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { loadWebMedia } from "../web/media.js";
|
||||
import { saveMediaBuffer } from "./store.js";
|
||||
|
||||
export async function resolveOutboundAttachmentFromUrl(
|
||||
mediaUrl: string,
|
||||
maxBytes: number,
|
||||
): Promise<{ path: string; contentType?: string }> {
|
||||
const media = await loadWebMedia(mediaUrl, maxBytes);
|
||||
const saved = await saveMediaBuffer(
|
||||
media.buffer,
|
||||
media.contentType ?? undefined,
|
||||
"outbound",
|
||||
maxBytes,
|
||||
);
|
||||
return { path: saved.path, contentType: saved.contentType };
|
||||
}
|
||||
Reference in New Issue
Block a user