From 2a0fb385f84032a8734c7f1ff30215db96913b98 Mon Sep 17 00:00:00 2001 From: The JavaScript / TypeScript Guy <40920737+theJsTsGuy@users.noreply.github.com> Date: Thu, 31 Mar 2022 16:47:22 +0500 Subject: [PATCH] Updated the Readme of Beta version (#58) * updated the readme of beta version * Added complete code snippet in readme * Prepare for v1 release * Prepare for v1 release Co-authored-by: Paul Mohr --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 533506e..498ef58 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@

An all in one Laravel backend for FilePond

+

We currently support the `process` and `revert` methods and are securing those via the Laravel encryption/decryption methods.

@@ -27,27 +28,30 @@ If you need to edit the configuration, you can publish it with: php artisan vendor:publish --provider="Sopamo\LaravelFilepond\LaravelFilepondServiceProvider" ``` -Included in this repo is a Filepond upload controller which is where you should direct uploads to. Upon upload the controller will return the `$serverId` which Filepond will send via a hidden input field (same name as the img) to be used in your own controller to move the file from temporary storage to somewhere permanent using the `getPathFromServerId($request->input('image'))` function. ```php // Get the temporary path using the serverId returned by the upload function in `FilepondController.php` $filepond = app(Sopamo\LaravelFilepond\Filepond::class); +$disk = config('filepond.temporary_files_disk'); + $path = $filepond->getPathFromServerId($serverId); +$fullpath = Storage::disk($disk)->get($filePath); + // Move the file from the temporary path to the final location $finalLocation = public_path('output.jpg'); -\File::move($path, $finalLocation); +\File::move($fullpath, $finalLocation); ``` #### External storage -You can use any [Laravel disk](https://laravel.com/docs/7.x/filesystem) as the storage for temporary files. If you use a different disk for temporary files and final location, you will need to copy the file from the temporary location to the new disk then delete the temporary file yourself. +You can use any [Laravel disk](https://laravel.com/docs/7.x/filesystem) as the storage for temporary files. If you use a different disk for the temporary files and the final location, you will need to copy the file from the temporary location to the new disk then delete the temporary file yourself. If you are using the default `local` disk, make sure the /storage/app/filepond directory exists in your project and is writable. -### Filepond setup +### Filepond client setup -Set at least the following Filepond configuration: +This is the minimum Filepond JS configuration you need to set after installing laravel-filepond. ```javascript FilePond.setOptions({ @@ -55,10 +59,10 @@ FilePond.setOptions({ url: '/filepond/api', process: '/process', revert: '/process', + patch: "?patch=", headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' } } }); ``` -