Plugin Directory

Changeset 2414079


Ignore:
Timestamp:
11/06/2020 08:33:16 PM (5 years ago)
Author:
stooit
Message:

Release 1.0.2.

Location:
quant
Files:
43 added
2 edited

Legend:

Unmodified
Added
Removed
  • quant/trunk/readme.txt

    r2411431 r2414079  
    66Tested up to: 5.5.1
    77Requires PHP: 7.2
    8 Stable tag: 1.0.1
     8Stable tag: 1.0.2
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4848== Changelog ==
    4949
     50= 1.0.2 =
     51* Performance improvement with added concurrency.
     52
    5053= 1.0.1 =
    5154* Added support for QuantSearch.
  • quant/trunk/src/Client.php

    r2411426 r2414079  
    123123     */
    124124    public function sendAttachments($media) {
     125        $attachments = [];
    125126
    126127        foreach ($media as $item) {
     
    143144
    144145            if (file_exists(ABSPATH . $file)) {
    145                 $this->file($file, ABSPATH . $file);
     146                $attachments[] = $file;
    146147            }
    147148        }
    148     }
     149
     150        $this->multipleFiles($attachments);
     151    }
     152
     153
     154    /**
     155     * Send multiple files in parallel to Quant API.
     156     *
     157     * @param array $files
     158     *      Array of files to send in parallel.
     159     */
     160    public function multipleFiles($files) {
     161
     162        $headers = $this->headers;
     163        $headers['Content-type']  = 'application/binary';
     164
     165        $requests = [];
     166
     167        foreach ($files as $file) {
     168            $headers['Quant-File-Url'] = $file;
     169            $path = ABSPATH . $file;
     170
     171            $requests[] = [
     172                'url' => $this->endpoint . '/file-upload?path=' . $path,
     173                'type' => 'POST',
     174                'headers' => $headers,
     175            ];
     176        }
     177
     178        // Register hook to alter curl opts on each handle.
     179        $hooks = new \Requests_Hooks();
     180        $hooks->register('curl.before_multi_add', function(&$data) {
     181            quant_attach_file($data);
     182        });
     183
     184        $options = [
     185          'hooks' => $hooks,
     186        ];
     187
     188        $requests = \Requests::request_multiple($requests, $options);
     189    }
     190
    149191
    150192    /**
Note: See TracChangeset for help on using the changeset viewer.