Exemplo n.º 1
0
 public function uploadAction()
 {
     $this->setContentTypeValue('text/plain');
     $validatedRequest = $this->getValidatedRequest('Media', 'Upload');
     $this->getBusiness()->checkUserRights('upload', array('websiteId' => $validatedRequest->getWebsiteId(), 'id' => $validatedRequest->getId(), 'albumId' => $validatedRequest->getAlbumId()));
     $upload = TransferFactory::getAdapter();
     $upload->setOptions(array('useByteString' => false));
     if (!$upload->isValid($validatedRequest->getFileInputname())) {
         throw new CmsException(220, __METHOD__, __LINE__);
     }
     $this->checkQuota($validatedRequest);
     $media = $this->createOrUpdateItemFromUploadRequest($upload, $validatedRequest);
     $this->setUploadedFileToMediaItem($upload, $media, $validatedRequest->getUploadFilename());
     $this->responseData->setData(array('id' => $media->getId()));
 }
Exemplo n.º 2
0
 /**
  * Haendelt den Import einer Datei
  *
  * @param  string $uploadFilename
  * @param  string $websiteId
  * @param  string $allowedType
  *
  * @return array
  * @throws \Cms\Exception
  */
 public function importUploadFile($uploadFilename, $websiteId, $allowedType)
 {
     $config = Registry::getConfig();
     $importDirectory = $config->import->directory;
     FS::createDirIfNotExists($importDirectory);
     $import = TransferFactory::getAdapter();
     $imports = $import->getFileInfo();
     if (isset($config->import->uploadFile) && isset($config->import->uploadFile->doNotRename)) {
         $renameUploadFile = new Boolean($config->import->uploadFile->doNotRename);
         $renameUploadFile = !$renameUploadFile->getValue();
     } else {
         $renameUploadFile = true;
     }
     if ($renameUploadFile) {
         $uploadFilename = basename($uploadFilename, '.zip') . '.P' . time() . '_' . rand(100000, 999999) . '.zip';
     }
     $import->addFilter('Rename', $uploadFilename);
     $import->setDestination($importDirectory);
     $import->receive();
     $importFile = $importDirectory . DIRECTORY_SEPARATOR . $uploadFilename;
     return $this->importFile($importFile, $websiteId, $allowedType);
 }
Exemplo n.º 3
0
 /**
  * Fake upload entfernen
  */
 protected function clearFakeUpload()
 {
     TransferFactory::clearAdapter();
     UploadValidatorFactory::clearValidator();
 }