Browse Source

fix: correct API parameter names for media save/load

Critical bug fix - the mediaStorage.ts functions were using incorrect
parameter names when calling the save-generation and load-generation APIs.

Fixed parameter mappings:
- workflowPath → directoryPath (API expects this name)
- id → imageId (API expects this name)
- data + type → video/audio (API expects media in named fields)
- Changed load from GET to POST with correct body structure

Also increased serverActions bodySizeLimit from 50mb to 100mb to handle
large video files during externalization.

This fixes the save failures when externalizing workflows with videos/audio.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
handoff-20260429-1057
Shrimbly 4 months ago
committed by shrimbly
parent
commit
c6fb1ad634
  1. 5
      next.config.ts
  2. 2
      src/app/api/save-generation/route.ts
  3. 26
      src/utils/mediaStorage.ts

5
next.config.ts

@ -4,9 +4,12 @@ const nextConfig: NextConfig = {
reactStrictMode: true,
experimental: {
serverActions: {
bodySizeLimit: "50mb",
bodySizeLimit: "100mb", // Increased for large media files
},
},
// Note: For route handlers (.../route.ts files), body size is controlled by
// the underlying server. For large payloads, consider using streaming or
// increase Node.js max HTTP header size if needed.
turbopack: {
root: __dirname,
},

2
src/app/api/save-generation/route.ts

@ -4,6 +4,8 @@ import * as path from "path";
import * as crypto from "crypto";
import { logger } from "@/utils/logger";
export const maxDuration = 300; // 5 minute timeout for large media operations
// Helper to get file extension from MIME type
function getExtensionFromMime(mimeType: string): string {
const mimeToExt: Record<string, string> = {

26
src/utils/mediaStorage.ts

@ -613,10 +613,9 @@ async function saveVideoAndGetRef(
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
workflowPath,
id: videoId,
data: videoData,
type: "video",
directoryPath: workflowPath,
imageId: videoId,
video: videoData,
}),
},
60000 // 60s timeout for larger video files
@ -680,10 +679,9 @@ async function saveAudioAndGetRef(
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
workflowPath,
id: audioId,
data: audioData,
type: "audio",
directoryPath: workflowPath,
imageId: audioId,
audio: audioData,
}),
},
60000 // 60s timeout for larger audio files
@ -1038,12 +1036,14 @@ async function loadMediaById(
response = await fetch(`/api/workflow-images?${params.toString()}`);
} else {
// Use load-generation API for videos and audio
const params = new URLSearchParams({
workflowPath,
id: mediaId,
response = await fetch("/api/load-generation", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
directoryPath: workflowPath,
imageId: mediaId,
}),
});
response = await fetch(`/api/load-generation?${params.toString()}`);
}
const result = await response.json();

Loading…
Cancel
Save