verschoben von innohub/k3s repo
This commit is contained in:
35
src/routes/api/list/[[vorgang]]/+server.js
Normal file
35
src/routes/api/list/[[vorgang]]/+server.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { client } from '$lib/minio';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params }) {
|
||||
const prefix = params.vorgang ? `${params.vorgang}/` : '';
|
||||
let stream = client.listObjectsV2('tatort', prefix, false, '');
|
||||
const result = new ReadableStream({
|
||||
start(controller) {
|
||||
stream.on('data', (data) => {
|
||||
if (prefix === '') {
|
||||
if (data.prefix)
|
||||
controller.enqueue(`${JSON.stringify({ ...data, name: data.prefix.slice(0, -1) })}\n`);
|
||||
return;
|
||||
}
|
||||
|
||||
const name = data.name.slice(prefix.length);
|
||||
if (name === 'config.json') return;
|
||||
|
||||
controller.enqueue(`${JSON.stringify({ ...data, name, prefix })}\n`);
|
||||
});
|
||||
stream.on('end', () => {
|
||||
controller.close();
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
stream.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
return new Response(result, {
|
||||
headers: {
|
||||
'content-type': 'text/event-stream'
|
||||
}
|
||||
});
|
||||
}
|
||||
26
src/routes/api/tatort/+server.js
Normal file
26
src/routes/api/tatort/+server.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { client } from '$lib/minio';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET() {
|
||||
var stream = client.listObjectsV2('tatort', '', true);
|
||||
const result = new ReadableStream({
|
||||
start(controller) {
|
||||
stream.on('data', (data) => {
|
||||
//console.log(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'
|
||||
}
|
||||
});
|
||||
}
|
||||
6
src/routes/api/upload/+server.js
Normal file
6
src/routes/api/upload/+server.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { client } from '$lib/minio';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET(params) {
|
||||
console.log('GET', params);
|
||||
}
|
||||
Reference in New Issue
Block a user