Member Junction
    Preparing search index...

    Action that compresses or decompresses files Supports ZIP format with various compression levels

    // Compress multiple files into ZIP
    await runAction({
    ActionName: 'File Compress',
    Params: [{
    Name: 'Operation',
    Value: 'compress'
    }, {
    Name: 'Files',
    Value: [
    { name: 'report.pdf', data: pdfBase64Data },
    { name: 'data.csv', data: csvData }
    ]
    }]
    });

    // Decompress ZIP file
    await runAction({
    ActionName: 'File Compress',
    Params: [{
    Name: 'Operation',
    Value: 'decompress'
    }, {
    Name: 'FileURL',
    Value: 'https://example.com/archive.zip'
    }]
    });

    // Compress with options
    await runAction({
    ActionName: 'File Compress',
    Params: [{
    Name: 'Operation',
    Value: 'compress'
    }, {
    Name: 'Files',
    Value: filesArray
    }, {
    Name: 'CompressionLevel',
    Value: 9
    }, {
    Name: 'OutputFileID',
    Value: true
    }]
    });

    Hierarchy

    • BaseFileHandlerAction
      • FileCompressAction
    Index

    Constructors

    Properties

    AuthorizesCaller: boolean

    True when the action authorizes its caller itself, so a public entry point such as the RunAction mutation may run it for an authenticated user without an MJ: Action Authorizations link. Set it only on an action that either checks an authorization the caller must hold, or reads and writes only with the caller's own permissions. Leave it false for an action that acts with more authority than its caller, or that reaches data or sends messages the caller chooses but could not otherwise reach.

    The engine reads the marker only from the class that runs, never from its parent classes. A subclass that overrides a marked action must declare the marker again.

    Methods

    • Get file content from various sources based on parameters Priority: FileID > FileURL > Data parameter

      Parameters

      • params: RunActionParams

        Action parameters

      • dataParamName: string

        Name of the parameter containing direct data

      • fileParamName: string = 'FileID'

        Name of the parameter containing file ID (default: 'FileID')

      • urlParamName: string = 'FileURL'

        Name of the parameter containing file URL (default: 'FileURL')

      Returns Promise<
          {
              content: string
              | Buffer;
              fileName?: string;
              mimeType?: string;
              source: "url" | "storage" | "direct";
          },
      >

      Object with content and metadata

    • Compresses or decompresses files

      Parameters

      • params: RunActionParams

        The action parameters containing:

        • Operation: "compress" | "decompress" (required)
        • For compress:
          • Files: Array of file objects with { name: string, data: string/Buffer }
          • CompressionLevel: 0-9 (default: 6, 0=store only, 9=maximum compression)
          • Format: "zip" (currently only ZIP supported)
        • For decompress:
          • FileID/FileURL/Data: Input compressed file
        • OutputFileID: Save result to MJ Storage (optional)
        • FileName: Name for output file (default: 'archive.zip' or 'extracted_files.json')

      Returns Promise<ActionResultSimple>

      Compressed/decompressed data

    • Executes the action with the provided parameters.

      Parameters

      Returns Promise<ActionResultSimple>

      Promise resolving to the action result

    • Save file to MJ Storage. Uploads the content to a FileStorageAccount and creates the corresponding MJ: Files entity record.

      Parameters

      • content: string | Buffer

        File content as string or Buffer

      • fileName: string

        Name for the file

      • mimeType: string

        MIME type of the file

      • params: RunActionParams

        Action parameters (for contextUser)

      • OptionalstorageAccountName: string

        Optional: name of the storage account to use (falls back to first active)

      • OptionalstoragePath: string

        Optional: custom storage path prefix (falls back to artifacts/{date}/{uuid}/)

      Returns Promise<string>

      The ID of the newly created MJ: Files record