25 lines
480 B
TypeScript
25 lines
480 B
TypeScript
import { client } from '$lib/minio';
|
|
|
|
export async function GET() {
|
|
const stream = client.listObjectsV2('tatort', '', true);
|
|
const result = new ReadableStream({
|
|
start(controller) {
|
|
stream.on('data', (data) => {
|
|
controller.enqueue(`${JSON.stringify(data)}\n`);
|
|
});
|
|
stream.on('end', () => {
|
|
controller.close();
|
|
});
|
|
},
|
|
cancel() {
|
|
stream.destroy();
|
|
}
|
|
});
|
|
|
|
return new Response(result, {
|
|
headers: {
|
|
'content-type': 'text/event-stream'
|
|
}
|
|
});
|
|
}
|