Skip to content

Commit

Permalink
Updated the Readme of Beta version (#58)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
omar-shahid and Sopamo authored Mar 31, 2022
1 parent 3ffcbeb commit 2a0fb38
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<p align="center">
<strong>An all in one Laravel backend for <a href="https://pqina.nl/filepond/" target="_blank">FilePond</a></strong><br>
</p>

<p>
We currently support the `process` and `revert` methods and are securing those via the Laravel encryption/decryption methods.
</p>
Expand All @@ -27,38 +28,41 @@ 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({
server: {
url: '/filepond/api',
process: '/process',
revert: '/process',
patch: "?patch=",
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}
});
```

0 comments on commit 2a0fb38

Please sign in to comment.