mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 06:34:31 +00:00
25 lines
711 B
TypeScript
25 lines
711 B
TypeScript
import { loadWebMedia } from "../web/media.js";
|
|
import { buildOutboundMediaLoadOptions } from "./load-options.js";
|
|
import { saveMediaBuffer } from "./store.js";
|
|
|
|
export async function resolveOutboundAttachmentFromUrl(
|
|
mediaUrl: string,
|
|
maxBytes: number,
|
|
options?: { localRoots?: readonly string[] },
|
|
): Promise<{ path: string; contentType?: string }> {
|
|
const media = await loadWebMedia(
|
|
mediaUrl,
|
|
buildOutboundMediaLoadOptions({
|
|
maxBytes,
|
|
mediaLocalRoots: options?.localRoots,
|
|
}),
|
|
);
|
|
const saved = await saveMediaBuffer(
|
|
media.buffer,
|
|
media.contentType ?? undefined,
|
|
"outbound",
|
|
maxBytes,
|
|
);
|
|
return { path: saved.path, contentType: saved.contentType };
|
|
}
|