You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
620 B

2 years ago
import * as config from './config';
import * as math from './math';
import * as storage from './storage';
export async function route(req) {
const url = new URL(req.url);
if (url.pathname === '/api/image') {
const desk_id = url.searchParams.get('deskId') || '0';
const formdata = await req.formData();
const file = formdata.get('file');
6 months ago
const image_id = math.crypto_random32();
2 years ago
Bun.write(config.IMAGEDIR + '/' + image_id, file);
2 years ago
return new Response(image_id);
} else if (url.pathname === '/api/ping') {
return new Response('pong');
2 years ago
}
6 months ago
}