Drop target rel path field from script upload
Every T5 script lands in the flat sp/ directory, so the target path is always just the uploaded filename. Removed the field from the Scripts upload form and the server derives targetRelPath from file.name. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -44,12 +44,13 @@ export async function GET() {
|
||||
}
|
||||
|
||||
// Multipart POST — creates a script + version 1 from a single file upload.
|
||||
// Fields: name (text), targetRelPath (text), scopeType (optional: 'game'|'map'),
|
||||
// scopeValue (optional string), notes (optional), content (file).
|
||||
// Fields: name (text), scopeType (optional: 'game'|'map'), scopeValue
|
||||
// (optional string), notes (optional), content (file). The target rel path
|
||||
// defaults to the uploaded filename — T5 servers keep all scripts in a flat
|
||||
// sp/ directory, so there's no sub-path to specify.
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
const form = await request.formData();
|
||||
const name = String(form.get('name') ?? '').trim();
|
||||
const targetRelPath = String(form.get('targetRelPath') ?? '').trim();
|
||||
const notes = form.get('notes') ? String(form.get('notes')) : undefined;
|
||||
let scopeType: ScopeType | null;
|
||||
try {
|
||||
@@ -62,6 +63,7 @@ export async function POST({ request }: { request: Request }) {
|
||||
const file = form.get('content');
|
||||
if (!(file instanceof File)) return json({ ok: false, error: 'content file is required' }, { status: 400 });
|
||||
|
||||
const targetRelPath = file.name;
|
||||
const content = Buffer.from(await file.arrayBuffer());
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user