コード例 #1
0
 /**
  * Store a file content.
  *
  * @param  UploadContext $context
  * @param $content
  * @param  array         $metadataMap
  * @return UploadedFile
  */
 public function store(UploadContext $context, $content, array $metadataMap = array())
 {
     $name = $this->namingStrategy->getName($context);
     $directory = $this->storageStrategy->getDirectory($context, $name);
     $path = $directory . '/' . $name;
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof MetadataSupporter) {
         $adapter->setMetadata($path, $this->resolveMetadataMap($context, $metadataMap));
     }
     $this->filesystem->write($path, $content);
     $file = $this->filesystem->get($path);
     return new UploadedFile($this, $file);
 }