Neos\Neos\Controller\Backend\ContentController::uploadAssetAction PHP Method

uploadAssetAction() public method

Depending on the $metadata argument it will return asset metadata for the AssetEditor or image metadata for the ImageEditor
public uploadAssetAction ( Asset $asset, string $metadata ) : string
$asset Neos\Media\Domain\Model\Asset
$metadata string Type of metadata to return ("Asset" or "Image")
return string
    public function uploadAssetAction(Asset $asset, $metadata)
    {
        $this->response->setHeader('Content-Type', 'application/json');
        /** @var Site $currentSite */
        $currentSite = $this->siteRepository->findOneByNodeName($this->request->getInternalArgument('__siteNodeName'));
        if ($currentSite !== null && $currentSite->getAssetCollection() !== null) {
            $currentSite->getAssetCollection()->addAsset($asset);
            $this->assetCollectionRepository->update($currentSite->getAssetCollection());
        }
        switch ($metadata) {
            case 'Asset':
                $result = $this->getAssetProperties($asset);
                if ($this->persistenceManager->isNewObject($asset)) {
                    $this->assetRepository->add($asset);
                }
                break;
            case 'Image':
                $result = $this->getImageInterfacePreviewData($asset);
                if ($this->persistenceManager->isNewObject($asset)) {
                    $this->imageRepository->add($asset);
                }
                break;
            default:
                $this->response->setStatus(400);
                $result = array('error' => 'Invalid "metadata" type: ' . $metadata);
        }
        return json_encode($result);
    }