pionl / laravel-chunk-upload

The basic implementation for chunk upload with multiple providers support like jQuery-file-upload, pupload, DropZone and resumable.js
MIT License
617 stars 167 forks source link

Change chunk directory location issues #133

Closed mmg-mike closed 2 years ago

mmg-mike commented 2 years ago

I've looked through docs and examples and I don't see a way to change the chunk directory location. I think it should be done when you instantiate FileReceiver, but I've tried many different ways and keep getting errors. Here's what my code looks like:

UploadController.php

$receiver = new FileReceiver(
    "file", 
     $request, 
     HandlerFactory::classFromRequest($request),
     "/change/directory/location/here"
);

Error

TypeError: Pion\Laravel\ChunkUpload\Save\ParallelSave::__construct(): Argument #3 ($chunkStorage) must be of type Pion\Laravel\ChunkUpload\Storage\ChunkStorage, string given, called in /app/vendor/pion/laravel-chunk-upload/src/Handler/Traits/HandleParallelUploadTrait.php on line 34 in file /app/vendor/pion/laravel-chunk-upload/src/Save/ParallelSave.php on line 45

The error indicates clearly that I should not pass a string, but I'm not sure what to put here instead?

I'd be glad to PR this into the docs once I understand how to do it properly.

pionl commented 2 years ago

Hi @lbz-life ,

the FileReceiver is full injectable so it is not possible do it this way. For this a config were you can change storage.

In filesystems.php make a new entry in disks:

 'mychunksfolder' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'visibility' => 'public',
        ],

Then in your config (like this file) change the storage.disk option with the name you have chosen

mmg-mike commented 2 years ago

@pionl thank you for the reply. This makes sense and I can now see in the documentation where this is outlined. I was looking at things a little different, so I'm guessing that is why I glossed right over it.

pionl commented 2 years ago

@lbz-life any hints were the docs can be improved?