Giter Site home page Giter Site logo

rafaeltovar / php-tus-aws-s3 Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 3.0 30 KB

Simple, light, minimum TUS server connected with AWS S3. Based on https://github.com/ankitpokhrel/tus-php

PHP 100.00%
tus tus-protocol php uploads php70 aws-s3 php-library resumable-upload chunked-uploads

php-tus-aws-s3's Introduction

Project not maintained

This project is not being maintained. Please use the original project ankitpokhrel/tus-php to ensure regular updates. Here are some notes about using the project with AWS S3.

PHP TUS protocol server for Amazon Web Service S3

Simple, light, minimum TUS server connected with AWS S3. Based on ankitpokhrel/tus-php.

Versions

If you are using Symfony, check the table below.

Symfony Version php-tus-aws-s3 version
^4.3 ~1.0
^5.0 or ^6.0 ~1.1

Installation

Composer

composer require rafaeltovar/php-tus-aws-s3:~1.x predis/predis

Features

  • Implements TUS protocol server for upload files
  • AWS S3 multiparts uploads
  • Uploads directly to AWS S3
  • Use Redis like data cache with Predis
  • Flysystem compatible

Documentation

Understanding TusPhpS3\Server class constructor

use TusPhp\Tus\Server as TusServer;

class Server
extends TusServer
{
    //...
    public function __construct(
        TusPhp\Cache\AbstractCache $cache,
        League\Flysystem\AwsS3v3\AwsS3Adapter $storage,
        TusPhpS3\Http\Request $request,
        $excludeAttrApiPath = [],
        $forceLocationSSL = true)
        {
            //...
        }
}
Property Type Details
$cache TusPhp\Cache\AbstractCache We are using TusPhpS3\Cache\PredisCache for Predis client.
$storage League\Flysystem\AwsS3v3\AwsS3Adapter This adapter contains the AWS S3 Client.
$request TusPhps3\Http\Request This object contain a Symfony\Component\HttpFoundation\Request.
$excludeAttrApiPath array Exclude some parts from Api path for create a real Api Base Path for TUS Server. For example, if my Api base path is https://example.com/uploads but my upload PATCH is http://example.com/uploads/{id} We need exclude ['id'].
$forceLocationSSL boolean Force location header property to https.

TUS Routes

/**
 * Create new upload
 * or get server configuration
 **/
$routes->add('uploads', '/api/uploads')
        ->controller([UploadController::class, 'upload'])
        ->methods([POST, OPTIONS])

/**
 * Upload files
 * or delete uploads
 **/
$routes->add('uploads', '/api/uploads/{id}')
        ->controller([UploadController::class, 'upload'])
        ->methods([PATCH, DELETE])

Running TUS Server

use TusPhpS3;

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;

use Symfony\Component\HttpFoundation\Request as HttpRequest;

class UploadController
{
    public function upload()
    {

        // redis connection
        $predis = new Predis\Client('tcp://10.0.0.1:6379');


        // AWS S3 Client
        $S3client = new S3Client([
            'credentials' => [
                'key'    => 'your-key',
                'secret' => 'your-secret',
            ],
            'region' => 'your-region',
            'version' => 'latest|version',
        ]);

        $server = new TusPhpS3\Server(
            new TusPhpS3\Cache\PredisCache($predis),
            new AwsS3Adapter($S3client, 'your-bucket-name', 'optional/path/prefix'),
            new TusPhpS3\Http\Request(HttpRequest::createFromGlobals()),
            ['id'],
            true
        );

        return $server->serve(); // return an TusPhpS3\Http\Response
    }
}

php-tus-aws-s3's People

Contributors

rafaeltovar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-tus-aws-s3's Issues

Getting error while installing through composer require rafaeltovar/php-tus-aws-s3

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install rafaeltovar/php-tus-aws-s3 v1.0.5
- Conclusion: don't install rafaeltovar/php-tus-aws-s3 v1.0.4
- Conclusion: don't install rafaeltovar/php-tus-aws-s3 v1.0.3
- Conclusion: don't install rafaeltovar/php-tus-aws-s3 v1.0.2
- Conclusion: don't install rafaeltovar/php-tus-aws-s3 v1.0.1
- Conclusion: remove guzzlehttp/guzzle 7.3.0
- Installation request for rafaeltovar/php-tus-aws-s3 ^1.0 -> satisfiable by rafaeltovar/php-tus-aws-s3[v1.0.0, v1.0.1, v1.0.2, v1.0.3, v1.0.4, v1.0.5].
- Conclusion: don't install guzzlehttp/guzzle 7.3.0
- rafaeltovar/php-tus-aws-s3 v1.0.0 requires guzzlehttp/guzzle ^6.4 -> satisfiable by guzzlehttp/guzzle[6.4.0, 6.4.1, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5].
- Can only install one of: guzzlehttp/guzzle[6.4.0, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.4.1, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.0, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.1, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.2, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.3, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.4, 7.3.0].
- Can only install one of: guzzlehttp/guzzle[6.5.5, 7.3.0].
- Installation request for guzzlehttp/guzzle (locked at 7.3.0) -> satisfiable by guzzlehttp/guzzle[7.3.0].

Installation failed, reverting ./composer.json to its original content.

Fresh composer require dependencies seem out of date

Problem 1
- rafaeltovar/php-tus-aws-s3 v1.0.0 requires vlucas/phpdotenv ^3.6 -> found vlucas/phpdotenv[v3.6.0, ..., 3.6.x-dev] but the package is fixed to v5.2.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- rafaeltovar/php-tus-aws-s3[v1.0.1, ..., v1.0.5] require guzzlehttp/guzzle ^6.4 -> found guzzlehttp/guzzle[6.4.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.0.1).
- Root composer.json requires rafaeltovar/php-tus-aws-s3 ^1.0 -> satisfiable by rafaeltovar/php-tus-aws-s3[v1.0.0, ..., v1.0.5].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.