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' => [

    ]

];

fineuploader-server's People

Contributors

esbenp avatar etorofiev avatar yeexel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fineuploader-server's Issues

$file->getType() being called after temp dir has been deleted

Laravel 5.4

I am getting the following error when I try upload with fineUploader:

ErrorException exif_imagetype(/home/vagrant/wed/storage/uploader/temp/a772c5d4-06a7-4b8f-aecf-7dd78c8c196e/59aee10d2c4f4.jpg): failed to open stream: No such file or directory

It seems that in prepareUploadSuccessfulResponse $file->getType() is called which is looking for the file in the temp dir, after the directory has been deleted in Uploader.php line 96

As a quick fix I have commented out the file_type line but would love to find a proper solution

private function prepareUploadSuccessfulResponse(array $response, RootFile $file)
{
    return array_merge($response, [
        'type' => 'upload',
        'success' => true,
        //'file_type' => $file->getType(),
        'original_name' => $file->getOriginalName(),
        'upload_path' => $this->clearFileExtension($file->getName())
    ]);
}

rename() is failing for files > 2MB

[2015-09-10 09:08:43] production.ERROR: exception 'ErrorException' with message 'rename(): No such file or directory' in /home/forge/default/vendor/optimus/fineuploa
der-server/src/Uploader.php:69
Stack trace:
#0 (): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /home/forge/default/vendor/optimus/fineuploader-server/src/Uploader.php(69): rename()
#2 /home/forge/default/vendor/optimus/fineuploader-server/src/Controller/LaravelController.php(27): Optimus\FineuploaderServer\Uploader->upload()
#3 (): Optimus\FineuploaderServer\Controller\LaravelController->upload()

Getting error Undefined index: optimus_uploader_thumbnail_height

Hi:
I have integrated fineuploader-server with laravel 5.4 and followed all the steps as described here https://github.com/esbenp/fineuploader-server/blob/master/README.md
but getting error Undefined index: optimus_uploader_thumbnail_height.

I created following route :

Route::group(['prefix' => 'uploader'], function () {

Route::post('/upload', '\Optimus\FineuploaderServer\Controller\LaravelController@upload');
Route::delete('/delete/{uuid}', '\Optimus\FineuploaderServer\Controller\LaravelController@delete');
Route::get('/session', '\Optimus\FineuploaderServer\Controller\LaravelController@session');

});
but getting MethodNotAllowed error on Route::post('/upload', '\Optimus\FineuploaderServer\Controller\LaravelController@upload');

changing it to Route;:get and changing method to 'GET' and paramsInBody to false.
This is my javascript code:

``javascript
    var restrictedUploader = new qq.FineUploader({
        element: document.getElementById("fine-uploader-validation"),
        template: 'qq-template-validation',
        request: {
            endpoint: "{{url('/').'/uploader/upload'}}",
            method: 'GET',
            paramsInBody:false
        },
        thumbnails: {
            placeholders: {
                waitingPath: "{{asset('/libraries/fine-uploader/placeholders/waiting-generic.png')}}",
                notAvailablePath: "{{asset('/libraries/fine-uploader/placeholders/not_available-generic.png')}}"
            }
        },
        validation: {
            allowedExtensions: ['jpeg', 'jpg', 'png'],
            itemLimit: 1,
            sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
        }
    });

``

where am i making mistakes ?

Directions for use?

Looks like a good package to get running with fineuploader, though how do you use it..?

config dir should be Config

On case-sensitive filesystems you get this error:

Class 'Optimus\FineuploaderServer\Config\Config' not found

The path expected is:

src/Config/Config.php

but it is:

src/config/Config.php

Install with laravel 9

Hi, I try to install this with sail composer require optimus/fineuploader-server:0.4.1 -W and I face
Problem 1

  • Root composer.json requires optimus/fineuploader-server 0.4.1 -> satisfiable by optimus/fineuploader-server[0.4.1].
  • optimus/fineuploader-server 0.4.1 requires laravel/framework ~6.0|~7.0|~8.0 -> found laravel/framework[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but it conflicts with your root composer.json require (^9.19).

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.