save() public method

Save the document in a storage and give back the path to the document.
public save ( $tempPath, $fileName, $version ) : mixed
$tempPath
$fileName
$version
return mixed
示例#1
0
 /**
  * Prepares data.
  *
  * @param UploadedFile  $uploadedFile
  * @param array         $data
  * @param UserInterface $user
  *
  * @return Media
  *
  * @throws InvalidFileException
  */
 private function buildData($uploadedFile, $data, $user)
 {
     if (!$uploadedFile instanceof UploadedFile) {
         throw new InvalidFileException('Given uploaded file is not of instance UploadedFile');
     }
     $this->validator->validate($uploadedFile);
     $data['storageOptions'] = $this->storage->save($uploadedFile->getPathname(), $uploadedFile->getClientOriginalName(), 1);
     $data['name'] = $uploadedFile->getClientOriginalName();
     $data['size'] = $uploadedFile->getSize();
     $data['mimeType'] = $uploadedFile->getMimeType();
     $data['type'] = ['id' => $this->typeManager->getMediaType($uploadedFile->getMimeType())];
     return $this->createMedia($data, $user);
 }