Spaces:
Sleeping
Sleeping
Download src/classes/core/PayloadPoster.ts from lamsaoganh/teamta: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/core/PayloadPoster.ts
- Command line
-
hf download hf://spaces/lamsaoganh/teamta/src/classes/core/PayloadPoster.ts
-
curl -L -o PayloadPoster.ts https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/core/PayloadPoster.ts
1.13 kB
| import { IPayloadPoster } from "../../interfaces/core/IPayloadPoster"; | |
| import { IPayloadReference } from "../../interfaces/core/IPayloadReference"; | |
| import { IStoragePoster } from "../../interfaces/core/IStoragePoster"; | |
| export class PayloadPoster implements IPayloadPoster { | |
| posters: IStoragePoster[]; | |
| constructor({ posters }: { posters: IStoragePoster[] }) { | |
| this.posters = posters; | |
| } | |
| postPayload = async (params: { payloadReference: IPayloadReference }): Promise<IPayloadReference> => { | |
| const payloadReference = params.payloadReference; | |
| if (payloadReference.storageType == "none") { | |
| return payloadReference; | |
| } | |
| // Tìm storage poster phù hợp để xử lý payloadReference | |
| const foundPoster = this.posters.find(poster => poster.storageType == payloadReference.storageType); | |
| if (!foundPoster) { | |
| throw new Error(`Không tìm thấy poster phù hợp để xử lý payload reference`); | |
| } | |
| const updatedReference = await foundPoster.post(payloadReference); | |
| return updatedReference; | |
| } | |
| } |