Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/he426100/tus-php-hyperf

The Hyperf Tus-php package.
https://github.com/he426100/tus-php-hyperf

hyperf resumable-upload tus tus-protocol

Last synced: about 4 hours ago
JSON representation

The Hyperf Tus-php package.

Awesome Lists containing this project

README

        

# Hyperf 可恢复文件上传组件

该组件移植了 Tus-php 组件([Tus-php](https://github.com/ankitpokhrel/tus-php ))相对完整的功能特性。

* Swoole无法获取 `php://input`,用 `Swoole\Http\Request->getContent()` 代替

## 安装

```shell script
composer require he426100/tus-php-hyperf
```

## 发布配置

```shell script
php bin/hyperf.php vendor:publish he426100/tus-php-hyperf
```

> 文件位于 `config/autoload/tus.php`。

## 使用示例

* hyperf/app/Controller/TusController.php
```
request, $this->response))->setUploadDir(\dirname(__DIR__, 3) . '/public/' . 'uploads');
return $server->serve();
}
}
```

* nano/index.php
```
config([
'cache.default' => [
'driver' => \Hyperf\Cache\Driver\RedisDriver::class,
'packer' => \Hyperf\Utils\Packer\PhpSerializerPacker::class,
'prefix' => 'c:',
],
]);

$app->addRoute(['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE'], '/', function() {
$server = new Server($this->request, $this->response);
return $server->serve();
});

$app->run();
```

* uppy.html
```



Uppy





var uppy = new Uppy.Core()
.use(Uppy.Dashboard, {
inline: true,
target: '#drag-drop-area'
})
.use(Uppy.Tus, {
endpoint: 'http://localhost:9501',
chunkSize: 1 * 1024 * 1024
})

uppy.on('complete', (result) => {
console.log('Upload complete! We’ve uploaded these files:', result.successful)
})

```