Pages corrections pages missions
This commit is contained in:
parent
435cf15eed
commit
9db972b80a
@ -5,14 +5,15 @@ import { prisma } from '@/lib/prisma';
|
|||||||
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
||||||
|
|
||||||
// Use the exact same S3 client configuration as mission-uploads.ts
|
// Use the exact same S3 client configuration as mission-uploads.ts
|
||||||
|
// Use hardcoded credentials as primary (same as mission-uploads.ts)
|
||||||
const missionsS3Client = new S3Client({
|
const missionsS3Client = new S3Client({
|
||||||
region: 'us-east-1',
|
region: 'us-east-1',
|
||||||
endpoint: 'https://dome-api.slm-lab.net',
|
endpoint: 'https://dome-api.slm-lab.net',
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: process.env.MINIO_ACCESS_KEY || '4aBT4CMb7JIMMyUtp4Pl',
|
accessKeyId: '4aBT4CMb7JIMMyUtp4Pl', // Primary: hardcoded (same as mission-uploads.ts)
|
||||||
secretAccessKey: process.env.MINIO_SECRET_KEY || 'HGn39XhCIlqOjmDVzRK9MED2Fci2rYvDDgbLFElg'
|
secretAccessKey: 'HGn39XhCIlqOjmDVzRK9MED2Fci2rYvDDgbLFElg' // Primary: hardcoded (same as mission-uploads.ts)
|
||||||
},
|
},
|
||||||
forcePathStyle: true
|
forcePathStyle: true // Required for MinIO
|
||||||
});
|
});
|
||||||
|
|
||||||
const MISSIONS_BUCKET = 'missions';
|
const MISSIONS_BUCKET = 'missions';
|
||||||
@ -68,7 +69,25 @@ export async function POST(
|
|||||||
|
|
||||||
// Construct the S3 key for the folder marker
|
// Construct the S3 key for the folder marker
|
||||||
// Files are stored in MinIO without the "missions/" prefix
|
// Files are stored in MinIO without the "missions/" prefix
|
||||||
const s3Key = path.endsWith('/') ? `${path}.placeholder` : `${path}/.placeholder`;
|
// The path from frontend might be relative (e.g., "attachments/Content") or absolute
|
||||||
|
// We need to ensure it includes the missionId
|
||||||
|
let folderPath = path;
|
||||||
|
if (!folderPath.startsWith(missionId)) {
|
||||||
|
// If path doesn't start with missionId, prepend it
|
||||||
|
folderPath = `${missionId}/${folderPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove "missions/" prefix if present (for consistency)
|
||||||
|
folderPath = folderPath.replace(/^missions\//, '');
|
||||||
|
|
||||||
|
const s3Key = folderPath.endsWith('/') ? `${folderPath}.placeholder` : `${folderPath}/.placeholder`;
|
||||||
|
|
||||||
|
console.log(`[POST /api/missions/${missionId}/files/folder] Creating folder:`, {
|
||||||
|
originalPath: path,
|
||||||
|
folderPath: folderPath,
|
||||||
|
s3Key: s3Key,
|
||||||
|
bucket: MISSIONS_BUCKET
|
||||||
|
});
|
||||||
|
|
||||||
// Create folder marker in S3
|
// Create folder marker in S3
|
||||||
await missionsS3Client.send(new PutObjectCommand({
|
await missionsS3Client.send(new PutObjectCommand({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user