UNPKG

dood-stream-client

Version:

🚀 A feature-rich client for the DoodStream API with caching, logging, and error handling

51 lines (50 loc) 1.55 kB
import { ErrorFactory } from "../errors/error-factory"; /** * 📤 Upload-related API functionality */ export class UploadApi { /** * Create a new Upload API instance * * @param client - HTTP client */ constructor(client) { this.client = client; } /** * 🖥️ Get upload server URL * * @returns Promise with upload server response */ async getUploadServer() { return this.client.get("/upload/server"); } /** * 📋 Get information about using the upload server * * @returns Object with information about uploading files */ getUploadInstructions() { return { curl_example: "curl -X POST -F 'api_key={your_api_key}' -F 'file=@file.mp4' {upload_server_url}", html_example: `<form enctype="multipart/form-data" action="{upload_server_url}" method="post"> <input type="hidden" name="api_key" value="{your_api_key}"> <input name="file" type="file"> <input type="submit"> </form>`, note: "Replace {your_api_key} with your actual API key and {upload_server_url} with the URL from getUploadServer()", }; } /** * 🔄 Clone/copy a file * * @param params - Clone file parameters * @returns Promise with clone file response */ async cloneFile(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required for cloning a file"); } return this.client.get("/file/clone", params); } }