feat: AI Brand Voice Translator integration and Mesh Content fix
This commit is contained in:
@@ -4,6 +4,7 @@ import fs from "fs";
|
||||
import crypto from "crypto";
|
||||
import { createServer as createViteServer } from "vite";
|
||||
import multer from "multer";
|
||||
import cors from "cors";
|
||||
|
||||
// ═══ Uploads directory ═══
|
||||
const UPLOADS_DIR = process.env.BRADLY_UPLOADS_DIR || path.join(process.cwd(), "uploads");
|
||||
@@ -51,6 +52,9 @@ export async function createExpressApp() {
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
|
||||
// Add CORS
|
||||
app.use(cors());
|
||||
|
||||
// Add JSON parser with generous limit for render payloads (timelineElements can be large)
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
|
||||
@@ -81,12 +85,12 @@ export async function createExpressApp() {
|
||||
app.post("/api/upload/brand", mediaUpload.single("file"), (req, res) => {
|
||||
try {
|
||||
if (!req.file) return res.status(400).json({ error: "No file uploaded" });
|
||||
const { brandId, workspacePath } = req.body;
|
||||
const { brandId, workspacePath, subfolder = "brand" } = req.body;
|
||||
if (!brandId || !workspacePath) {
|
||||
return res.status(400).json({ error: "brandId and workspacePath required" });
|
||||
}
|
||||
|
||||
const brandDir = path.join(workspacePath, brandId, "brand");
|
||||
const brandDir = path.join(workspacePath, brandId, subfolder);
|
||||
if (!fs.existsSync(brandDir)) {
|
||||
fs.mkdirSync(brandDir, { recursive: true });
|
||||
}
|
||||
@@ -99,7 +103,7 @@ export async function createExpressApp() {
|
||||
fs.renameSync(req.file.path, finalPath);
|
||||
|
||||
// Return the public URL that routes through our dynamic /workspace middleware
|
||||
const publicUrl = `http://localhost:3000/workspace/${brandId}/brand/${finalFilename}`;
|
||||
const publicUrl = `http://localhost:3000/workspace/${brandId}/${subfolder}/${finalFilename}`;
|
||||
res.json({ url: publicUrl, path: finalPath });
|
||||
} catch (error) {
|
||||
console.error("Brand upload error:", error);
|
||||
|
||||
Reference in New Issue
Block a user