mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-27 03:11:21 +08:00
Introduces new OneBot actions for streaming file upload and download, including chunked file transfer with memory/disk management and SHA256 verification. Adds CleanStreamTempFile, DownloadFileStream, UploadFileStream, and TestStreamDownload actions, updates action routing and network adapters to support streaming via HTTP and WebSocket, and provides Python test scripts for concurrent upload testing.
24 lines
806 B
TypeScript
24 lines
806 B
TypeScript
import { ActionName } from '@/onebot/action/router';
|
|
import { OneBotAction, OneBotRequestToolkit } from '@/onebot/action/OneBotAction';
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
|
|
|
const SchemaData = Type.Object({
|
|
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
export class TestStreamDownload extends OneBotAction<Payload, string> {
|
|
override actionName = ActionName.TestStreamDownload;
|
|
override payloadSchema = SchemaData;
|
|
|
|
async _handle(_payload: Payload, _adaptername: string, _config: NetworkAdapterConfig, req: OneBotRequestToolkit) {
|
|
for (let i = 0; i < 10; i++) {
|
|
req.send({ index: i });
|
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
}
|
|
return 'done';
|
|
}
|
|
}
|