Compare commits
No commits in common. "196b91ae6a41dd7a397d3247d8167235a61b6b7b" and "ed9c54da1ddd1993c8f092fa9c74df41ee0705fe" have entirely different histories.
196b91ae6a
...
ed9c54da1d
|
|
@ -63,14 +63,14 @@ uploadRouter.post(
|
|||
`[${timestamp}] [${requestId}] Uploading file: ${file.originalname} as ${imageId} (${file.size} bytes)`,
|
||||
);
|
||||
|
||||
const uploadResult = await storageService.uploadFile({
|
||||
const uploadResult = await storageService.uploadFile(
|
||||
orgSlug,
|
||||
projectSlug,
|
||||
imageId,
|
||||
buffer: file.buffer,
|
||||
contentType: file.mimetype,
|
||||
originalFilename: file.originalname,
|
||||
});
|
||||
file.buffer,
|
||||
file.mimetype,
|
||||
file.originalname,
|
||||
);
|
||||
|
||||
if (!uploadResult.success) {
|
||||
const errorResponse: UploadFileResponse = {
|
||||
|
|
|
|||
|
|
@ -197,16 +197,15 @@ imagesRouter.post(
|
|||
|
||||
try {
|
||||
const storageService = await StorageFactory.getInstance();
|
||||
const imageId = randomUUID();
|
||||
|
||||
const uploadResult = await storageService.uploadFile({
|
||||
orgSlug: orgId,
|
||||
const uploadResult = await storageService.uploadFile(
|
||||
orgId,
|
||||
projectSlug,
|
||||
imageId,
|
||||
buffer: file.buffer,
|
||||
contentType: file.mimetype,
|
||||
originalFilename: file.originalname,
|
||||
});
|
||||
'uploads',
|
||||
file.originalname,
|
||||
file.buffer,
|
||||
file.mimetype,
|
||||
);
|
||||
|
||||
if (!uploadResult.success) {
|
||||
res.status(500).json({
|
||||
|
|
|
|||
|
|
@ -70,14 +70,14 @@ export class ImageGenService {
|
|||
// Original filename for metadata (e.g., "my-image.png")
|
||||
const originalFilename = `generated-image.${generatedData.fileExtension}`;
|
||||
|
||||
const uploadResult = await storageService.uploadFile({
|
||||
orgSlug: finalOrgSlug,
|
||||
projectSlug: finalProjectSlug,
|
||||
const uploadResult = await storageService.uploadFile(
|
||||
finalOrgSlug,
|
||||
finalProjectSlug,
|
||||
imageId,
|
||||
buffer: generatedData.buffer,
|
||||
contentType: generatedData.mimeType,
|
||||
generatedData.buffer,
|
||||
generatedData.mimeType,
|
||||
originalFilename,
|
||||
});
|
||||
);
|
||||
|
||||
if (uploadResult.success) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Client as MinioClient } from 'minio';
|
||||
import { StorageService, FileMetadata, UploadResult, UploadFileParams } from './StorageService';
|
||||
import { StorageService, FileMetadata, UploadResult } from './StorageService';
|
||||
|
||||
export class MinioStorageService implements StorageService {
|
||||
private client: MinioClient;
|
||||
|
|
@ -102,9 +102,14 @@ export class MinioStorageService implements StorageService {
|
|||
return await this.client.bucketExists(this.bucketName);
|
||||
}
|
||||
|
||||
async uploadFile(params: UploadFileParams): Promise<UploadResult> {
|
||||
const { orgSlug, projectSlug, imageId, buffer, contentType, originalFilename } = params;
|
||||
|
||||
async uploadFile(
|
||||
orgSlug: string,
|
||||
projectSlug: string,
|
||||
imageId: string,
|
||||
buffer: Buffer,
|
||||
contentType: string,
|
||||
originalFilename?: string,
|
||||
): Promise<UploadResult> {
|
||||
// Validate inputs first
|
||||
this.validatePath(orgSlug, projectSlug, imageId);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,15 +21,6 @@ export interface UploadResult {
|
|||
error?: string;
|
||||
}
|
||||
|
||||
export interface UploadFileParams {
|
||||
orgSlug: string;
|
||||
projectSlug: string;
|
||||
imageId: string;
|
||||
buffer: Buffer;
|
||||
contentType: string;
|
||||
originalFilename?: string;
|
||||
}
|
||||
|
||||
export interface StorageService {
|
||||
/**
|
||||
* Create the main bucket if it doesn't exist
|
||||
|
|
@ -44,8 +35,22 @@ export interface StorageService {
|
|||
/**
|
||||
* Upload a file to storage
|
||||
* Path format: {orgSlug}/{projectSlug}/img/{imageId}
|
||||
*
|
||||
* @param orgSlug Organization slug
|
||||
* @param projectSlug Project slug
|
||||
* @param imageId UUID for the file (same as image.id in DB)
|
||||
* @param buffer File buffer
|
||||
* @param contentType MIME type
|
||||
* @param originalFilename Original filename from user (for metadata)
|
||||
*/
|
||||
uploadFile(params: UploadFileParams): Promise<UploadResult>;
|
||||
uploadFile(
|
||||
orgSlug: string,
|
||||
projectSlug: string,
|
||||
imageId: string,
|
||||
buffer: Buffer,
|
||||
contentType: string,
|
||||
originalFilename?: string,
|
||||
): Promise<UploadResult>;
|
||||
|
||||
/**
|
||||
* Download a file from storage
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# @base = http://localhost:3000
|
||||
@base = https://api.banatie.app
|
||||
@apiKey = bnt_415a15747796a9676cb47c663fcede36af3583cedaec19893b831ec7a2ae0311
|
||||
@base = http://localhost:3000
|
||||
@apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d
|
||||
|
||||
###############################################################################
|
||||
# BASIC GENERATION TESTS
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
@base = http://localhost:3000
|
||||
# @base = https://api.banatie.app
|
||||
# @apiKey = bnt_e6eb544c505922b9bfe5b088e067fc3940efff16b1b88585c5518946630d4a66
|
||||
|
||||
@apiKey = bnt_415a15747796a9676cb47c663fcede36af3583cedaec19893b831ec7a2ae0311
|
||||
@apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d
|
||||
|
||||
###############################################################################
|
||||
# IMAGE UPLOAD & CRUD TESTS
|
||||
|
|
|
|||
Loading…
Reference in New Issue