t3xbu10dr: Publish video posts through the media pipeline and upgrade thumbnails to the player
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import { SESSION_COOKIE } from "@/lib/cookie";
|
||||
import { createTextPost } from "@/lib/post-create";
|
||||
import { createImagePost } from "@/lib/post-media";
|
||||
import { createMediaPost } from "@/lib/post-media";
|
||||
|
||||
// POST /api/posts
|
||||
// - JSON { content } -> public text post
|
||||
// - multipart/form-data content+file -> public image post (one file)
|
||||
// - multipart/form-data content+file -> public image or video post (one file)
|
||||
// Both create a public draft on the feed, then publish it, and return { id }.
|
||||
// For an image the server also uploads the bytes to a presigned URL and confirms
|
||||
// the upload; the browser never receives the feed token. The create call can
|
||||
@@ -31,7 +31,7 @@ export async function POST(req: NextRequest) {
|
||||
} catch {
|
||||
return NextResponse.json({ error: "bad_file" }, { status: 400 });
|
||||
}
|
||||
const result = await createImagePost(sessionId, content, file);
|
||||
const result = await createMediaPost(sessionId, content, file);
|
||||
if (!result.ok) {
|
||||
return NextResponse.json({ error: result.error }, { status: result.status });
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ button:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.post-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
|
||||
.post-media img { display: block; width: 100%; height: auto; border-radius: 8px; }
|
||||
.post-video { background: #000; border-radius: 8px; overflow: hidden; }
|
||||
.post-video-pending { color: #fff; padding: 48px 12px; text-align: center; }
|
||||
.post-video video { display: block; width: 100%; max-height: 520px; background: #000; }
|
||||
.post-stats { display: flex; gap: 16px; color: var(--grey); font-size: 14px; }
|
||||
.heart { color: var(--red); }
|
||||
@@ -52,6 +53,7 @@ button:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.composer-image span { padding: 6px 12px; border: 1px solid #999; background: #fafafa; }
|
||||
.composer-image input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
|
||||
.composer-preview { display: flex; align-items: center; gap: 10px; }
|
||||
.composer-preview video { width: 96px; height: 64px; object-fit: cover; border: 1px solid var(--line); background: #000; }
|
||||
.composer-preview img { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--line); }
|
||||
.composer-filename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.composer-remove { margin: 0; padding: 6px 12px; border-radius: 0; }
|
||||
|
||||
Reference in New Issue
Block a user