fix: file access
This commit is contained in:
parent
5c8bc90bcc
commit
0b6bb5662c
|
|
@ -65,6 +65,7 @@ services:
|
||||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
||||||
MINIO_BROWSER_REDIRECT_URL: http://localhost:9001
|
MINIO_BROWSER_REDIRECT_URL: http://localhost:9001
|
||||||
MINIO_SERVER_URL: http://localhost:9000
|
MINIO_SERVER_URL: http://localhost:9000
|
||||||
|
MINIO_DOMAIN: localhost
|
||||||
# CRITICAL: SNMD command for full S3 compatibility
|
# CRITICAL: SNMD command for full S3 compatibility
|
||||||
command: server /data{1...4} --console-address ":9001"
|
command: server /data{1...4} --console-address ":9001"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
@base = http://localhost:3000
|
@base = http://localhost:3000
|
||||||
|
|
||||||
|
|
||||||
|
### Health
|
||||||
|
|
||||||
|
GET {{base}}/health
|
||||||
|
|
||||||
|
|
||||||
### Info
|
### Info
|
||||||
|
|
||||||
GET {{base}}/api/info
|
GET {{base}}/api/info
|
||||||
|
|
@ -30,15 +36,8 @@ POST {{base}}/api/text-to-image
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"prompt": "банановый стимпанк. много стимпанк машин и меаханизмов посвященных бананм и работающих на бананах. банановая феерия",
|
"prompt": "A majestic eagle soaring over snow-capped mountains",
|
||||||
"filename": "banatie-party",
|
"filename": "test-eagle"
|
||||||
"autoEnhance": true,
|
|
||||||
"enhancementOptions": {
|
|
||||||
"imageStyle": "photorealistic",
|
|
||||||
"aspectRatio": "landscape",
|
|
||||||
"mood": "peaceful",
|
|
||||||
"lighting": "golden hour"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,23 +24,7 @@ imagesRouter.get(
|
||||||
const storageService = StorageFactory.getInstance();
|
const storageService = StorageFactory.getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Method 1: Redirect to presigned URL (24 hour expiry)
|
// Stream the file directly through our API (more reliable than presigned URL redirects)
|
||||||
const presignedUrl = await storageService.getPresignedDownloadUrl(
|
|
||||||
orgId,
|
|
||||||
projectId,
|
|
||||||
category as 'uploads' | 'generated' | 'references',
|
|
||||||
filename,
|
|
||||||
24 * 60 * 60 // 24 hours
|
|
||||||
);
|
|
||||||
|
|
||||||
// Redirect to the presigned URL
|
|
||||||
return res.redirect(302, presignedUrl);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to generate presigned URL:', error);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Method 2: Fallback - Stream the file directly through our API
|
|
||||||
const fileBuffer = await storageService.downloadFile(
|
const fileBuffer = await storageService.downloadFile(
|
||||||
orgId,
|
orgId,
|
||||||
projectId,
|
projectId,
|
||||||
|
|
@ -65,14 +49,13 @@ imagesRouter.get(
|
||||||
|
|
||||||
return res.send(fileBuffer);
|
return res.send(fileBuffer);
|
||||||
|
|
||||||
} catch (streamError) {
|
} catch (error) {
|
||||||
console.error('Failed to stream file:', streamError);
|
console.error('Failed to stream file:', error);
|
||||||
return res.status(404).json({
|
return res.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'File not found'
|
message: 'File not found'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,20 @@ export class MinioStorageService implements StorageService {
|
||||||
expirySeconds: number = 86400 // 24 hours default
|
expirySeconds: number = 86400 // 24 hours default
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const filePath = this.getFilePath(orgId, projectId, category, filename);
|
const filePath = this.getFilePath(orgId, projectId, category, filename);
|
||||||
return await this.client.presignedGetObject(this.bucketName, filePath, expirySeconds);
|
const presignedUrl = await this.client.presignedGetObject(this.bucketName, filePath, expirySeconds);
|
||||||
|
|
||||||
|
// Replace internal Docker hostname with public URL if configured
|
||||||
|
if (this.publicUrl) {
|
||||||
|
const clientEndpoint = this.client.host + (this.client.port ? `:${this.client.port}` : '');
|
||||||
|
const publicEndpoint = this.publicUrl.replace(/^https?:\/\//, '');
|
||||||
|
|
||||||
|
return presignedUrl.replace(
|
||||||
|
`${this.client.protocol}//${clientEndpoint}`,
|
||||||
|
this.publicUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return presignedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
async listProjectFiles(
|
async listProjectFiles(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue