📄
FilesWorkflow Docs
  • 👏Welcome
    • Introduction to FilesWorkflow
    • Key features and benefits
  • 🧡Get Started
    • Account creation
    • Personal & Organization
    • Basic interface navigation
    • Tasks & Workflows
    • Browser-task & Server-task
    • Public & Private
    • Run task & workflow
    • Controlled Sharing
    • Creating workflows
    • Limitations
    • Official Tasks & Workflows
    • How to protect your file security
  • 💻Developer
    • Creating custom tasks
    • Advanced settings for tasks
    • Task Writing Guide
    • Task examples
    • Task templates
    • Generate scripts using AI
  • 💎Pricing and Plans
    • Plan comparisons
    • Change Plan
  • ❓FAQ
  • 📃Legal
    • Privacy Policy
    • Terms of Service
  • 📒Release Note
Powered by GitBook
On this page
  1. Developer

Task Writing Guide

PreviousAdvanced settings for tasksNextTask examples

Last updated 10 months ago

  1. Language:

    • Scripts are written in JavaScript.

    • TypeScript can be used and compiled to JavaScript.

  2. Development Environment:

    • Simple scripts can be written and tested directly in the task's script editor.

    • Complex scripts or those requiring third-party libraries should be compiled before importing.

    • Templates are available for reference ().

  3. Module Standard:

    • Scripts follow the ES module standard.

    • Export the task module using syntax like: export default async function (files, params)

  4. Function Type:

    • Task function is asynchronous.

    • await syntax is supported within the function.

  5. Function Parameters:

    • Two parameters: files and params

    • files: Type FileList (even for single input, it's a FileList with length 1)

    • params: An object containing task or workflow parameters, accessed via keys (e.g., params.quality)

    • onProgressMsg: A callback function (progressMsg: string) => void

  6. Function Return:

    • Return a Promise of a processed FileList or File array.

    • If nothing is returned, the input files will be returned.

  7. Error Handling:

    • Throw errors directly, e.g., throw new Error("The quality in the parameters is invalid.")

  8. Important Notes:

    • Do not include sensitive/confidential data in scripts. Use environment variables for such data.

    • Optimize scripts to run within 5 minutes. Executions exceeding 5 minutes will fail.

    • Keep script size under 10MB.

Following these guidelines will help ensure your scripts are efficient, secure, and compatible with the FilesWorkflow platform.

💻
Template Link