zimbra-api/upload-api

PHP wrapper library around the Zimbra upload service

3.0.0 2024-04-25 08:49 UTC

This package is auto-updated.

Last update: 2024-04-26 03:19:55 UTC


README

PHP wrapper library around the Zimbra upload service.

Requirement

  • PHP 8.1.x or later,
  • PSR Discovery library for searching installed http clients and http message factories,
  • (optional) PHPUnit to run tests,

Installation

Via Composer

$ composer require zimbra-api/upload-api

or just add it to your composer.json file directly.

{
    "require": {
        "zimbra-api/upload-api": "*"
    }
}

This package using PSR-17: HTTP Factories, PSR-18: HTTP Client for creating multipart stream & sending HTTP requests to Zimbra upload service. Make sure to install package(s) providing "http client implementation" & "http factory implementation". The recommended package is Guzzle which provide both PSR-17 & PSR-18.

$ composer require guzzlehttp/guzzle

Basic usage of zimbra upload client

<?php

require_once 'vendor/autoload.php';

use Zimbra\Upload\Client;
use Zimbra\Upload\Request;

$file = new \SplFileInfo($filePath);
$request = new Request([$file], $requestId, $authToken);
$client = new Client('https://zimbra.server/service/upload');
$attachments = $client->upload($request);

$authToken is user authentication token, it can obtain from zimbra soap api.

<?php

require_once 'vendor/autoload.php';

use Zimbra\Account\AccountApi;

$api = new AccountApi('https://zimbra.server/service/soap');
$auth = $api->authByName('username', 'password');
$authToken = $auth->getAuthToken();

Licensing

BSD 3-Clause

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.