diff --git a/src/index.ts b/src/index.ts index ccbd119..fc7e808 100644 --- a/src/index.ts +++ b/src/index.ts @@ -167,20 +167,7 @@ export async function exportActorProfile({ return { addMediaFile(fileName: string, buffer: ArrayBuffer, contentType: string) { - pack.entry( - { - name: `media/${fileName}`, - size: buffer.byteLength - }, - Buffer.from(buffer) - ) - - // Add media metadata to the manifest - manifest.contents.media.contents[fileName] = { - type: contentType, - size: buffer.byteLength, - lastModified: new Date().toISOString() - } + addMediaFile(pack, manifest, fileName, buffer, contentType) }, finalize() { @@ -244,3 +231,26 @@ export async function importActorProfile(tarBuffer: Buffer): Promise { stream.pipe(extract) }) } + +function addMediaFile( + pack: Pack, + manifest: any, + fileName: string, + buffer: ArrayBuffer, + contentType: string +): void { + pack.entry( + { + name: `media/${fileName}`, + size: buffer.byteLength + }, + Buffer.from(buffer) + ) + + // Add media metadata to the manifest + manifest.contents.media.contents[fileName] = { + type: contentType, + size: buffer.byteLength, + lastModified: new Date().toISOString() + } +}