Code Monkey home page Code Monkey logo

fineuploader-server's Introduction

Fineuploader Server

Build Status Coverage Status

Installation

composer require optimus/fineuploader-server 0.3.*

Usage

This is basically some wrapper classes around Fine Uploader's PHP server example.

1. Publish/edit configuration

If you are using Laravel you can integrate the uploader server by adding the service provider to your config/app.php

config/app.php

// ... other service providers
Optimus\FineuploaderServer\Provider\LaravelServiceProvider::class

Then publish the configuration

php artisan vendor:publish

2. Create routes and controller methods

Somewhere in your routes file(s)

$router->post('/uploader/upload', '\Optimus\FineuploaderServer\Controller\LaravelController@upload');
$router->delete('/uploader/delete/{uuid}', '\Optimus\FineuploaderServer\Controller\LaravelController@delete');
$router->get('/uploader/session', '\Optimus\FineuploaderServer\Controller\LaravelController@session');

3. Upload

This works fairly straight forward out of the box with fineuploader. I have not tried it with "vanilla" fineuploader but use the server with fineuploader-client

Basically you send uploads to POST /uploader/upload. Delete using DELETE /uploader/delete/{uuid}. And repopulate the uploader using GET /uploader/session.

Configuration

When publishing assets you will publish uploader.php to your configs directory. It is already populated with some sensible defaults. If you wish for the uploader to generate thumbnails using the thumbnail creator middleware you have to install the package as well using.

composer require optimus/fineuploader-server-thumbnail-creator 0.1.*

You can also choose to use Cloudinary as a storage backend. Here is an example of how your configuration could look like using a Cloudinary backend. Notice the thumbnail middleware is missing since the Cloudinary storage provider will add it automatically using Cloudinary.

config/uploader.php

<?php

return [

    'uploader_folder' => storage_path() . '/uploader',

    'temp_folder' => '/temp',

    'fine_uploader' => [

        'allowed_extensions' => [],
        'size_limit'    => 20*1024*1024, // 20 Mb
        'input_name'    => 'qqfile',
        'chunks_folder' => '/chunks'

    ],

    // Can be overridden by client
    'thumbnails' => [
        'height' => 100,
        'width' => 100,
        'crop' => 'fill'
    ],

    'storage' => 'cloudinary',

    'storage_url_resolver' => [
        'class' => Optimus\FineuploaderServer\Http\CloudinaryUrlResolver::class
    ],

    'success_response_class' => Optimus\FineuploaderServer\Response\OptimusResponse::class,

    'storages' => [

        'local' => [
            'class' => Optimus\FineuploaderServer\Storage\LocalStorage::class,
            'config' => [
                'root_folder' => storage_path() . '/uploader'
            ]
        ],

        'cloudinary' => [
            'class' => Optimus\FineuploaderServer\Storage\CloudinaryStorage::class,
            'config' => [
                'cloud_name' => env('CLOUDINARY_CLOUD_NAME', 'cloud_name'),
                'api_key' => env('CLOUDINARY_API_KEY'),
                'api_secret' => env('CLOUDINARY_API_SECRET')
            ]
        ]

    ],

    'naming_strategy' => Optimus\FineuploaderServer\Naming\UniqidStrategy::class,

    'middleware' => [

    ]

];

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.