Download mail action

@param string $file
@return \yii\console\Response|Response
@throws NotFoundHttpException
775004
public function actionDownloadMail($file)
    {
        $filePath = Yii::getAlias($this->module->panels['mail']->mailPath) . '/' . basename($file);

        if ((mb_strpos($file, '\\') !== false || mb_strpos($file, '/') !== false) || !is_file($filePath)) {
            throw new NotFoundHttpException('Mail file not found');
        }

        return Yii::$app->response->sendFile($filePath);
    }
513685
public function download($id = null, $file = null) {
		$type = $this->_controller->RequestHandler->prefers();
		$exportFileName = null;
		if (method_exists($this->_model, 'getExportFilename')) {
			$exportFileName = $this->_model->getExportFilename($id, true);
		}

		$exportPath = $this->_getExportDir();
		$downloadFile = $exportPath . $file;
		if (!empty($type)) {
			$downloadFile .= '.' . $type;
		}

		if (!file_exists($downloadFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid file for downloading'));
		}

		if (!empty($type) && !empty($exportFileName)) {
			$this->_controller->response->type($type);
			$exportFileName .= '.' . $type;
		}
		$responseOpt = [
			'download' => true,
		];
		if (!empty($exportFileName)) {
			if ($this->_controller->request->is('msie')) {
				$exportFileName = rawurlencode($exportFileName);
			}
			$responseOpt['name'] = $exportFileName;
		}
		$this->_controller->response->file($downloadFile, $responseOpt);

		return $this->_controller->response;
	}
209695
public function loadFile($file)
    {
        if (!file_exists($file)) {
            throw new LoaderException("Requested file '{$file}' doesn't exist");
        }

        $data = include($file);

        if (!is_array($data)) {
            throw new LoaderException("Requested file '{$file}' is expected to return an array");
        }

        return $data;
    }
1083916
protected function loadFile($file)
    {
        if (!stream_is_local($file)) {
            throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
        }

        if (!file_exists($file)) {
            throw new \InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
        }

        return $this->validate($this->parser->parse(file_get_contents($file)), $file);
    }
1182878
public function load_from_file($file)
    {
        $success = false;

        foreach ($this->resolve_paths($file) as $fpath) {
            if ($fpath && is_file($fpath) && is_readable($fpath)) {
                // use output buffering, we don't need any output here
                ob_start();
                include($fpath);
                ob_end_clean();

                if (is_array($config)) {
                    $this->merge($config);
                    $success = true;
                }
                // deprecated name of config variable
                if (is_array($rcmail_config)) {
                    $this->merge($rcmail_config);
                    $success = true;
                }
            }
        }

        return $success;
    }
136387
public function AcceptCheck($file = '') {
        if (!F("present")) {
            #获取当下文件目录结构
            $present = $this->get_dir_list();
            F("present", to_json($present));
        }
        $residue = $this->CloneSpy($file['check'], $file['delete']);
        $upload  = $this->getLocalFile($residue['local']);
        $data    = array(
            "url"    => $this->domain() . "/this7.php?type=download",
            "save"   => $upload,
            "update" => $residue['line'],
            "delete" => $residue['delete'],
        );
        $url = $file['url'];
        return $this->httpPost($url, $data);
    }
69162
static function resolveFileResolvable(string $file) {
        $rfile = @\realpath($file);
        if($rfile) {
            if(self::$filesystem) {
                return self::$filesystem->getContents($file);
            }
            
            return \React\Promise\resolve(\file_get_contents($rfile));
        } elseif(\filter_var($file, FILTER_VALIDATE_URL)) {
            return \CharlotteDunois\Yasmin\Utils\URLHelpers::resolveURLToData($file);
        }
        
        return \React\Promise\reject(new \RuntimeException('Given file is not resolvable'));
    }
1126062
public function sendFile($file) {
        $reader = $file->reader();
        if (!$reader || !$reader->isReadable()) {
            return;
        }

		if(class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
			return $reader->read();
		}
        
        $type = HTTP::get_mime_type($file->Filename);
        $disposition = strpos($type, 'image') !== false ? 'inline' : 'attachment';

		header('Content-Description: File Transfer');
		// Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)
		header(sprintf('Content-Disposition: %s; filename="%s"', $disposition, basename($file->Filename)));
		header('Content-Length: ' . $file->FileSize);
		header('Content-Type: ' . $type);
		header('Content-Transfer-Encoding: binary');

		// Ensure we enforce no-cache headers consistently, so that files accesses aren't cached by CDN/edge networks
		header('Pragma: no-cache');
		header('Cache-Control: private, no-cache, no-store');
        
        increase_time_limit_to(0);

		// Clear PHP buffer, otherwise the script will try to allocate memory for entire file.
		while (ob_get_level() > 0) {
			ob_end_flush();
		}

		// Prevent blocking of the session file by PHP. Without this the user can't visit another page of the same
		// website during download (see http://konrness.com/php5/how-to-prevent-blocking-php-requests/)
		session_write_close();

        echo $reader->read();
		die();
	}
572076
public function addFile($file)
    {
        if (!is_file($file)) {
            throw new MailException("File not found.", E_USER_ERROR);
        }

        $this->attachement[] = $file;

        return $this;
    }
594580
public static function downloadStatic($file, $headers = array()) {

        if (!is_array($headers)) {
            $headers = array();
        }

        $headers = array_merge(array(
            'Content-Type' => 'application/octet-stream'
        ), $headers);

        $respone = new BinaryFileResponse(
            $file,
            $status = 200,
            $headers,
            $public = true,
            $contentDisposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT,
            $autoEtag = true,
            $autoLastModified = true
        );

        return $respone;
    }
922260
public function file($file, $text=null, $download=null, $class=null) {
		if (is_null($text)) {
			// if no text is given, we use the text originally provided by the user
			$text = $file;
		}
		$file = $this->getLink($file);
		$attributes = $this->getHtmlAttributes(array('class'=>$class));

		if ($this->isTrue($download)) {
			// try to force download - http://stackoverflow.com/a/21527905/426224
			$attributes .= " download target='_blank'";
		}

		return "<a href='$file'$attributes>$text</a>";
	}
714017
@GET
  @Path("/download/{file}")
  public Response downloadFile(final @PathParam("file") String file) {
    Config config = createConfig();
    String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);
    String filePath = uploadDir + "/" + file;
    return getResponseByFile(filePath);
  }
776877
public function file($file)
    {
        $filePaths = loader()->getPublicDirs(true);

        foreach ($filePaths as $filePath) {
            if (is_file($filePath . $file)) {
                return path_to_url($filePath . $file);
                break;
            }
        }
    }
356415
public function load(string $file)
    {
        $file = $this->sanitizeFileName($file);
        if (empty($this->loaded)
            && !empty($this->beforeFirstTimeLoadCallBack)
            && $this->isValid()
        ) {
            $callback = $this->beforeFirstTimeLoadCallBack;
            $callback($this);
            $this->beforeFirstTimeLoadCallBack = false;
        }

        $this->loaded[$file] = isset($this->loaded[$file])
            ? $this->loaded[$file]+1
            : 1;
        return RequireBinding::with(($this->getThemePath() . $file), $this);
    }
395466
public function loadFile($file)
    {
        if (!is_file($file)) {
            throw new \RuntimeException(sprintf('File: %s not found.', $file));
        }

        $this->body = function () use ($file) {
            return file_get_contents($file);
        };

        $this->setFilename(pathinfo($file, PATHINFO_BASENAME));

        return $this;
    }
212062
public function fileGetContents($file)
    {
        $client = new Client();
        $response = $client->createRequest()
            ->setMethod('get')
            ->setUrl($file)
            ->addHeaders(['user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'])
            ->setOptions([
                'timeout' => $this->readFileTimeout, // set timeout to 1 seconds for the case server is not responding
            ])
            ->send();

        if ($response->isOk) {
            return $response->content;
        }

        throw new \Exception("File get contents '{$file}' error: ".$response->content);
    }
855962
private function loadFile($file)
    {

        $f = array();
        if (file_exists($file))
            try {
                $f = parse_ini_file($file, true);
            } catch (\Exception $ex) {
                throw new \OWeb\manage\exceptions\Settings("Failed to load Settings file : '$file'", 0, $ex);
            }

        return $f;

    }