node-libcurl

    Class CurlMime

    CurlMime class that acts as a wrapper around the native libcurl mime handle.

    C++ source code

    This class is used to create MIME structures for multipart form data uploads. It replaces the deprecated HTTPPOST option and provides more flexibility and features.

    The MIME API is available in libcurl 7.56.0 and later. If you're using an older version of libcurl, you'll need to use the deprecated HTTPPOST option instead.

    Basic usage:

    import { Curl, CurlMime } from 'node-libcurl'

    const curl = new Curl()
    const mime = new CurlMime(curl)

    mime
    .addPart()
    .setName('field_name')
    .setData('field_value')

    mime
    .addPart()
    .setName('file')
    .setFileData('/path/to/file.txt')

    curl.setOpt('URL', 'https://httpbin.org/post')
    curl.setOpt('MIMEPOST', mime)
    curl.perform()
    Index

    Constructors

    Methods

    Constructors

    • Creates a new MIME structure associated with an Easy or Curl handle.

      Parameters

      • handle: Easy | Curl

        The Easy or Curl handle this MIME structure will be associated with

      Returns CurlMime

      const curl = new Curl()
      const mime = new CurlMime(curl)
      const easy = new Easy()
      const mime = new CurlMime(easy)

    Methods

    MMNEPVFCICPMFPCPTTAAATR