public function onUpload(PostPersistEvent $event)
    {
        $file = $event->getFile();
        if (!$file instanceof FlysystemFile) {
            return;
        }

        $originalFilename = $file->getBasename();
        try {
            // Couldn't find anything better with OneUp uploader...
            $originalFiles = $event->getRequest()->files->all();
            if (isset($originalFiles['files'])) {
                $originalFiles = $originalFiles['files'];
                if (count($originalFiles)) {
                    $originalFile = array_pop($originalFiles);
                    $originalFilename = $originalFile->getClientOriginalName();
                }
            }
        } catch (\Exception $e) {
        }

        $file = $this->resourceManager->addFile($file, $originalFilename, $event->getType());

        /** @var AbstractResponse $response */
        $response = $event->getResponse();
        $response[] = $file;

        return $response;
    }
public function onUpload(PostPersistEvent $event)
    {
        $file = $event->getFile();
        if (!$file instanceof FlysystemFile) {
            return;
        }

        $originalFilename = $file->getBasename();
        try {
            // Couldn't find anything better with OneUp uploader...
            $originalFiles = $event->getRequest()->files->all();
            if (isset($originalFiles['files'])) {
                $originalFiles = $originalFiles['files'];
                if (count($originalFiles)) {
                    $originalFile = array_pop($originalFiles);
                    $originalFilename = $originalFile->getClientOriginalName();
                }
            }
        } catch (\Exception $e) {
        }

        $file = $this->resourceManager->addFile($file, $originalFilename, $event->getType());

        /** @var AbstractResponse $response */
        $response = $event->getResponse();
        $response[] = $file;

        return $response;
    }
@param PostPersistEvent $event

@throws \UnexpectedValueException
@throws \InvalidArgumentException
@throws \RuntimeException

@return AbstractResponse