Fix image edit disk upload so stills persist before Generate.
Reject only real handoff frames, return 400 with reason, keep the new still in the client library, and surface missing-still errors from Generate instead of 500s. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,9 +7,13 @@ export default defineEventHandler(async event => {
|
||||
const {owner}=assertLibraryOwner(event),folderId=field('folderId')
|
||||
assertFolderAccess(event,folderId)
|
||||
const size=imageDimensions(image.data)
|
||||
if (!size) throw createError({statusCode:400,statusMessage:'Use a PNG, JPEG, WebP, GIF, or BMP image.'})
|
||||
if (!size) throw createError({statusCode:400,statusMessage:'Use a PNG, JPEG, or WebP'})
|
||||
const filename=image.filename!.split(/[\\/]/).at(-1)!
|
||||
const still=await saveStill({ownerKey:owner,folderId,filename,name:filename.replace(/\.[^.]+$/,''),data:image.data,...size,hideInput:field('hideInput')==='true',role:'input'})
|
||||
if (!still) throw createError({statusCode:400,statusMessage:'This file was recognized as an internal video handoff frame and was not added. Choose a regular source image.'})
|
||||
return {still,...publicLibrary(event,{light:true})}
|
||||
if (!still?.id) throw createError({statusCode:400,statusMessage:'Could not save that image to the library.'})
|
||||
const library=publicLibrary(event,{light:true})
|
||||
const stills=library.stills.some(item=>item.id===still.id)
|
||||
? library.stills
|
||||
: [{...still,role:'input' as const},...library.stills]
|
||||
return {still,...library,stills}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user