feat: add images references
This commit is contained in:
parent
a38c2dd954
commit
bbc007bccd
|
|
@ -10,6 +10,7 @@ import type {
|
|||
import { ImageService } from './ImageService';
|
||||
import { AliasService } from './AliasService';
|
||||
import { ImageGenService } from '../ImageGenService';
|
||||
import { StorageFactory } from '../StorageFactory';
|
||||
import { buildWhereClause, buildEqCondition } from '@/utils/helpers';
|
||||
import { ERROR_MESSAGES, GENERATION_LIMITS } from '@/utils/constants';
|
||||
import type { ReferenceImage } from '@/types/api';
|
||||
|
|
@ -170,13 +171,36 @@ export class GenerationService {
|
|||
const buffers: ReferenceImage[] = [];
|
||||
const metadata: Array<{ imageId: string; alias: string }> = [];
|
||||
|
||||
// TODO: Implement proper storage key parsing and download
|
||||
// For now, we'll skip reference image buffers and just store metadata
|
||||
const storageService = await StorageFactory.getInstance();
|
||||
|
||||
for (const [alias, resolution] of resolutions) {
|
||||
if (!resolution.image) {
|
||||
throw new Error(`${ERROR_MESSAGES.ALIAS_NOT_FOUND}: ${alias}`);
|
||||
}
|
||||
|
||||
const parts = resolution.image.storageKey.split('/');
|
||||
if (parts.length < 4) {
|
||||
throw new Error(`Invalid storage key format: ${resolution.image.storageKey}`);
|
||||
}
|
||||
|
||||
const orgId = parts[0]!;
|
||||
const projId = parts[1]!;
|
||||
const category = parts[2]! as 'uploads' | 'generated' | 'references';
|
||||
const filename = parts.slice(3).join('/');
|
||||
|
||||
const buffer = await storageService.downloadFile(
|
||||
orgId,
|
||||
projId,
|
||||
category,
|
||||
filename
|
||||
);
|
||||
|
||||
buffers.push({
|
||||
buffer,
|
||||
mimetype: resolution.image.mimeType,
|
||||
originalname: filename,
|
||||
});
|
||||
|
||||
metadata.push({
|
||||
imageId: resolution.imageId,
|
||||
alias,
|
||||
|
|
|
|||
Loading…
Reference in New Issue