I'm trying to use dropzone with 1up-lab/OneupUploaderBundle. Upload is working well, and I'm trying to use my custom namer. My configuration:
oneup_uploader:
mappings:
products:
namer: app.upload_namer
use_orphanage: true
frontend: dropzone
storage:
directory: "%kernel.root_dir%/../data/products/"
Service conf
app.upload_namer:
class: AppBundle\Uploader\Naming\UploadNamer
arguments: ["@security.token_storage"]
My Namer:
class UploadNamer implements NamerInterface
{
private $tokenStorage;
private $productName;
public function __construct(TokenStorage $tokenStorage){
$this->tokenStorage = $tokenStorage;
}
/**
* Creates a user directory name for the file being uploaded.
*
* @param FileInterface $file
* @return string The directory name.
*/
public function name(FileInterface $file)
{
$userName = $this->tokenStorage->getToken()->getUser();
return sprintf('%s/%s.%s',
$userName,
uniqid(),
$file->getExtension()
);
}
}
I need to pass a folder name ($productName) to my namer, so I can use it to create storage folder:
products/$userName/$productName/$filename.ext
This variable will come from my form:
formData.append("productName", "loremipsum");
How can I can retrieve this parameter from my Namer ?
Thank you!