download_file无效文件404而不是200

时间:2017-09-25 10:18:06

标签: concrete5 concrete5-8.x

当我们尝试下载荣耀文件" /download_file/view/myFile.test"时,有没有办法抛出404而不是200?具体5.我使用的是版本8.2.1

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

解决方案是覆盖DownloadFile控制器和视图方法:

namespace Application\Controller\SinglePage;

use PageController;
use Core;
use Page;
use Permissions;
use Concrete\Core\Entity\File\File as FileEntity;
use Concrete\Core\File\File;
use Concrete\Controller\SinglePage\DownloadFile as CoreDownloadFile;

class DownloadFile extends CoreDownloadFile
{
    /**
     * @param int $fID
     * @param null $rcID
    * @return bool
     */
    public function view($fID = 0, $rcID = null)
    {
      //your code
      //redirect to 404 whenever you want: 
      $this->replace('/page_not_found');

      //...
    }
}