feat(video): enhance video management UI and functionality
- Refactor VideoBulkActions.vue to remove unused imports. - Update VideoFilters.vue to improve search and status filtering with new UI components from PrimeVue. - Modify VideoTable.vue to enhance action buttons for editing, copying, and deleting videos, using PrimeVue Button components. - Implement saveImageFromStream function in merge.ts to handle thumbnail image uploads. - Add new animation rule for card spring effect in uno.config.ts. - Create FileUploadType.vue icon component for local and remote file uploads. - Introduce CopyVideoModal.vue for sharing video links with enhanced user experience. - Add DetailVideoModal.vue for editing video details with form validation using Zod. - Establish new display routes in display.ts for handling thumbnail and metadata updates.
This commit is contained in:
@@ -214,3 +214,19 @@ export function streamManifest(manifest: Manifest): ReadableStream<Uint8Array> {
|
||||
},
|
||||
})
|
||||
}
|
||||
export async function saveImageFromStream(stream: ArrayBuffer, filename: string): Promise<void> {
|
||||
// Implement this function to save the thumbnail image stream to storage and update the database with the thumbnail URL
|
||||
const url = `${S3_ENDPOINT}/${BUCKET_NAME}/${filename}.jpg`;
|
||||
|
||||
const response = await aws.fetch(url, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'image/jpeg',
|
||||
},
|
||||
body: stream,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to save thumbnail: ${response.status} ${await response.text()}`)
|
||||
}
|
||||
}
|
||||
23
src/server/routes/display.ts
Normal file
23
src/server/routes/display.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Hono } from 'hono';
|
||||
import { saveImageFromStream } from '../modules/merge';
|
||||
|
||||
export function registerDisplayRoutes(app: Hono) {
|
||||
// app.get('/manifest/:id', async (c) => {
|
||||
// const manifest = await getListFiles();
|
||||
// if (!manifest) {
|
||||
// return c.json({ error: "Manifest not found" }, 404);
|
||||
// }
|
||||
// return c.json(manifest);
|
||||
// });
|
||||
app.put('/display/:id/thumbnail', async (c) => {
|
||||
const arrayBuffer = await c.req.arrayBuffer();
|
||||
await saveImageFromStream(arrayBuffer, crypto.randomUUID());
|
||||
return c.body('ok');
|
||||
// nhận rawData, lưu vào storage, cập nhật url thumbnail vào database
|
||||
|
||||
});
|
||||
app.put('/display/:id/metadata', async (c) => {
|
||||
|
||||
});
|
||||
app.post('/display/:id/subs', async (c) => {});
|
||||
}
|
||||
Reference in New Issue
Block a user