First, you need to install KnpGaufretteBundle, a Symfony integration of Gaufrette which will handle the file storage on places your want.
In your composer.json
file, add srio/rest-upload-bundle
:
{
"require": {
"srio/rest-upload-bundle": "~2.0.0"
}
}
Then, update your dependencies:
composer update srio/rest-upload-bundle
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new SRIO\RestUploadBundle\SRIORestUploadBundle(),
);
}
In your configuration file, create your Gaufrette filesystem. Let's start with a local filesystem storage in the web/uploads
directory.
# app/config/config.yml
knp_gaufrette:
adapters:
local_uploads:
local:
directory: %kernel.root_dir%/../web/uploads
filesystems:
uploads:
adapter: local_uploads
Then, we just have to configure the bundle to use the Gaufrette storage:
srio_rest_upload:
storages:
default:
filesystem: gaufrette.uploads_filesystem
If you want to use the resumable upload way, you have to configure it.
Then, start using it.