missions s3
This commit is contained in:
parent
f1db84bca7
commit
bf36e3de80
@ -64,7 +64,7 @@ export async function GET(request: Request, props: { params: Promise<{ missionId
|
||||
// Add public URLs to attachments
|
||||
const attachmentsWithUrls = attachments.map(attachment => ({
|
||||
...attachment,
|
||||
publicUrl: getPublicUrl(attachment.filePath, S3_CONFIG.missionsBucket)
|
||||
publicUrl: getPublicUrl(attachment.filePath, S3_CONFIG.bucket)
|
||||
}));
|
||||
|
||||
return NextResponse.json(attachmentsWithUrls);
|
||||
|
||||
@ -82,10 +82,10 @@ export async function GET(request: Request, props: { params: Promise<{ missionId
|
||||
// Add public URLs to mission logo and attachments
|
||||
const missionWithUrls = {
|
||||
...mission,
|
||||
logoUrl: mission.logo ? getPublicUrl(mission.logo, S3_CONFIG.missionsBucket) : null,
|
||||
logoUrl: mission.logo ? getPublicUrl(mission.logo, S3_CONFIG.bucket) : null,
|
||||
attachments: mission.attachments.map((attachment: { id: string; filename: string; filePath: string; fileType: string; fileSize: number; createdAt: Date }) => ({
|
||||
...attachment,
|
||||
publicUrl: getPublicUrl(attachment.filePath, S3_CONFIG.missionsBucket)
|
||||
publicUrl: getPublicUrl(attachment.filePath, S3_CONFIG.bucket)
|
||||
}))
|
||||
};
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ export async function GET(request: Request) {
|
||||
// Transform logo paths to public URLs
|
||||
const missionsWithPublicUrls = missions.map(mission => ({
|
||||
...mission,
|
||||
logo: mission.logo ? getPublicUrl(mission.logo, S3_CONFIG.missionsBucket) : null
|
||||
logo: mission.logo ? getPublicUrl(mission.logo, S3_CONFIG.bucket) : null
|
||||
}));
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
@ -148,7 +148,7 @@ export async function POST(request: Request) {
|
||||
console.log('Logo uploaded successfully to path:', filePath);
|
||||
|
||||
// Generate public URL
|
||||
const publicUrl = getPublicUrl(filePath, S3_CONFIG.missionsBucket);
|
||||
const publicUrl = getPublicUrl(filePath, S3_CONFIG.bucket);
|
||||
console.log('Public URL for logo:', publicUrl);
|
||||
|
||||
// Update mission record with logo path
|
||||
@ -184,7 +184,7 @@ export async function POST(request: Request) {
|
||||
console.log('Attachment uploaded successfully to path:', filePath);
|
||||
|
||||
// Generate public URL
|
||||
const publicUrl = getPublicUrl(filePath, S3_CONFIG.missionsBucket);
|
||||
const publicUrl = getPublicUrl(filePath, S3_CONFIG.bucket);
|
||||
console.log('Public URL for attachment:', publicUrl);
|
||||
|
||||
// Create attachment record in database
|
||||
|
||||
@ -42,21 +42,21 @@ export async function uploadMissionLogo(
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
console.log('Buffer created, size:', buffer.length);
|
||||
|
||||
// Upload to Minio using the missions bucket
|
||||
console.log('Creating S3 command with bucket:', S3_CONFIG.missionsBucket);
|
||||
// Upload to Minio using the pages bucket instead of missions bucket
|
||||
console.log('Creating S3 command with bucket:', S3_CONFIG.bucket);
|
||||
console.log('S3 config:', {
|
||||
endpoint: S3_CONFIG.endpoint || 'MISSING!',
|
||||
region: S3_CONFIG.region || 'MISSING!',
|
||||
bucket: S3_CONFIG.missionsBucket || 'MISSING!',
|
||||
bucket: S3_CONFIG.bucket || 'MISSING!',
|
||||
hasAccessKey: !!S3_CONFIG.accessKey || 'MISSING!',
|
||||
hasSecretKey: !!S3_CONFIG.secretKey || 'MISSING!'
|
||||
});
|
||||
|
||||
// Log the full path being used
|
||||
console.log('FULL S3 PATH:', `${S3_CONFIG.endpoint}/${S3_CONFIG.missionsBucket}/${filePath}`);
|
||||
console.log('FULL S3 PATH:', `${S3_CONFIG.endpoint}/${S3_CONFIG.bucket}/${filePath}`);
|
||||
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: S3_CONFIG.missionsBucket,
|
||||
Bucket: S3_CONFIG.bucket,
|
||||
Key: filePath,
|
||||
Body: buffer,
|
||||
ContentType: file.type,
|
||||
@ -120,11 +120,11 @@ export async function uploadMissionAttachment(
|
||||
console.log('Buffer created, size:', buffer.length);
|
||||
|
||||
// Log the full path being used
|
||||
console.log('FULL S3 PATH:', `${S3_CONFIG.endpoint}/${S3_CONFIG.missionsBucket}/${filePath}`);
|
||||
console.log('FULL S3 PATH:', `${S3_CONFIG.endpoint}/${S3_CONFIG.bucket}/${filePath}`);
|
||||
|
||||
// Upload to Minio using missions bucket
|
||||
// Upload to Minio using pages bucket
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: S3_CONFIG.missionsBucket,
|
||||
Bucket: S3_CONFIG.bucket,
|
||||
Key: filePath,
|
||||
Body: buffer,
|
||||
ContentType: file.type,
|
||||
@ -170,7 +170,7 @@ export async function uploadMissionAttachment(
|
||||
async function generateMissionPresignedUrl(key: string, expiresIn = 3600): Promise<string> {
|
||||
try {
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: S3_CONFIG.missionsBucket,
|
||||
Bucket: S3_CONFIG.bucket,
|
||||
Key: key
|
||||
});
|
||||
|
||||
@ -227,7 +227,7 @@ export async function generateMissionAttachmentUploadUrl(
|
||||
async function deleteMissionObject(key: string): Promise<boolean> {
|
||||
try {
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: S3_CONFIG.missionsBucket,
|
||||
Bucket: S3_CONFIG.bucket,
|
||||
Key: key
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user