示例#1
0
 /**
  * {@inheritDoc}
  */
 public function create($fileName, $originalName, $type, $userId)
 {
     $fileHistory = new FileHistory();
     $fileHelper = new FileHelper();
     $fileName = $fileHelper->generatePath($fileName, false) . $fileName;
     $fileHistory->setFileName($fileName);
     $fileHistory->setOriginalName($originalName);
     $fileHistory->setType($type);
     if ($userId == null) {
         $fileHistory->setUserId($this->getAuthUserId());
     } else {
         $fileHistory->setUserId($userId);
     }
     return $fileHistory;
 }
示例#2
0
 private function storeFile($file, $isImage = false)
 {
     $rootDir = $this->kernel->getRootDir();
     $articleFileDir = $rootDir . '/../web/uploads/articlefiles/';
     $journalUploadDir = $rootDir . '/../web/uploads/journal/';
     if ($isImage) {
         $fileHelper = new FileHelper();
         $generatePath = $fileHelper->generatePath($file['filename'], false);
         if (!is_dir($journalUploadDir . $generatePath) || !is_dir($journalUploadDir . 'croped/' . $generatePath)) {
             mkdir($journalUploadDir . $generatePath, 0775, true);
             mkdir($journalUploadDir . 'croped/' . $generatePath, 0775, true);
         }
         $filePath = $generatePath . $file['filename'];
         file_put_contents($journalUploadDir . $filePath, base64_decode($file['encoded_content']));
         file_put_contents($journalUploadDir . 'croped/' . $filePath, base64_decode($file['encoded_content']));
         return $filePath;
     } else {
         $fs = new Filesystem();
         $fs->mkdir($articleFileDir);
         $fs->dumpFile($articleFileDir . $file['filename'], base64_decode($file['encoded_content']));
         return $file['filename'];
     }
 }
示例#3
0
 private function storeFile($file, $isImage = false)
 {
     $rootDir = $this->kernel->getRootDir();
     $journalUploadDir = $rootDir . '/../web/uploads/journal/';
     if ($isImage) {
         $fileHelper = new FileHelper();
         $generatePath = $fileHelper->generateRandomPath();
         if (!is_dir($journalUploadDir . $generatePath) || !is_dir($journalUploadDir . 'croped/' . $generatePath)) {
             mkdir($journalUploadDir . $generatePath, 0775, true);
             mkdir($journalUploadDir . 'croped/' . $generatePath, 0775, true);
         }
         $filePath = $generatePath . $file['filename'];
         file_put_contents($journalUploadDir . $filePath, base64_decode($file['encoded_content']));
         file_put_contents($journalUploadDir . 'croped/' . $filePath, base64_decode($file['encoded_content']));
         $this->apiHelper->createFileHistory($filePath, $filePath, 'journal', $this->om, true);
         return $filePath;
     }
 }
示例#4
0
 public function name(FileInterface $file)
 {
     $fileHelper = new FileHelper();
     $fileName = sprintf('%s.%s', uniqid(), $file->getExtension());
     return $fileHelper->generatePath($fileName, false) . $fileName;
 }
示例#5
0
 /**
  * @param $file
  * @param bool $isImage
  * @return string
  */
 private function storeFile($file, $isImage = false)
 {
     $fs = new Filesystem();
     $rootDir = $this->kernel->getRootDir();
     $issueFileDir = $rootDir . '/../web/uploads/issuefiles/';
     $journalUploadDir = $rootDir . '/../web/uploads/journal/';
     $fileHelper = new FileHelper();
     $randomPath = $fileHelper->generateRandomPath();
     $generateRandomPath = $randomPath . $file['filename'];
     if ($isImage) {
         $fs->dumpFile($journalUploadDir . $generateRandomPath, base64_decode($file['encoded_content']));
         $fs->dumpFile($journalUploadDir . 'croped/' . $generateRandomPath, base64_decode($file['encoded_content']));
         $this->apiHelper->createFileHistory($generateRandomPath, $generateRandomPath, 'journal', $this->om, true);
         return $generateRandomPath;
     } else {
         $fs->dumpFile($issueFileDir . $generateRandomPath, base64_decode($file['encoded_content']));
         $this->apiHelper->createFileHistory($generateRandomPath, $generateRandomPath, 'issuefiles', $this->om, true);
         return $generateRandomPath;
     }
 }
示例#6
0
 private function storeFile($file)
 {
     if (!is_array($file)) {
         return $file;
     }
     $fileHelper = new FileHelper();
     $rootDir = $this->kernel->getRootDir();
     $issueFileDir = $rootDir . '/../web/uploads/issuefiles/';
     $generateUniqueFilePath = $fileHelper->generateRandomPath() . $file['filename'];
     $fs = new Filesystem();
     $fs->mkdir($issueFileDir);
     $fs->dumpFile($issueFileDir . $generateUniqueFilePath, base64_decode($file['encoded_content']));
     $this->apiHelper->createFileHistory($generateUniqueFilePath, $generateUniqueFilePath, 'issuefiles', $this->om, true);
     return $generateUniqueFilePath;
 }