orajo/zf2-tus-server

Laminas (PHP)库,用于tus服务器,基于Simon Leblanc的php-tus库。

v3.0.5 2024-01-03 11:26 UTC

This package is auto-updated.

Last update: 2024-09-03 12:57:26 UTC


README

tus服务器 (tus协议1.0)库

安装

使用composer

服务器使用

此库依赖于Flysystem

/**
 * Laminas action for uploading files
 */
public function uploadAction() {
     // Create and configure server
    $debug = false;
    // The internal adapter
    $adapter = new League\Flysystem\Local\LocalFilesystemAdapter(
        __DIR__.'/storage/'
    );

    // The FilesystemOperator
    $filesystem = new League\Flysystem\Filesystem($adapter);

    $server = new \ZfTusServer\Server('/path/to/save/file', 
                           $this->getRequest(),
                           $adapter
                           $debug
    );

    // Run server
    $server->process(true);
}

如果你使用的是Apache服务器,添加一个.htaccess文件以重定向PHP页面上的所有请求(如果没有,你的PATCH调用将失败),如下所示

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

作者

Jaroslaw Wasilewski orajo@windowslive.com

此库基于Simon Leblanc的库(https://github.com/leblanc-simon/php-tuscontact@leblanc-simon.eu

许可证

MIT