Get a Response instance that will force the browser to download the file, even if the browser can display it.

@return \Concrete\Core\Http\Response
174966
public function buildForceDownloadResponse()
    {
        $fre = $this->getFileResource();

        $fs = $this->getFile()->getFileStorageLocationObject()->getFileSystemObject();
        $response = new FlysystemFileResponse($fre->getPath(), $fs);

        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);

        return $response;
    }
987364
public static function get() {
		
		$req = new static();
		
		$post = \file_get_contents('php://input');
		
		if($post !== false){
			$obj = Json::deserialise($post);
			if($obj !== null){
				$req->_Obj = $obj;
			}
		}
		
		return $req;
		
	}
1089269
function response()
    {
        if (!$this->response) {
            $settings = new DataParseResponsePhp;
            $response = new HttpResponse(
                new BuildHttpResponse( BuildHttpResponse::parseWith($settings) )
            );

            $this->response = $response;
        }

        return $this->response;
    }
1169567
public function getResponse()
    {
        if(!$this->_response instanceof DispatcherResponseInterface) {
            $this->_response = clone $this->getObject('dispatcher.response', array(
                'request' => $this->getRequest(),
                'user'    => $this->getUser()
            ));
        }

        return $this->_response;
    }
509480
public function getResponse()
    {
        if (is_null($this->response)) {
            $this->response = $this->getRunner()->run();
        }
        return $this->response;
    }
416082
protected function handlePatch() : HttpResponse
    {
        $uploadKey = $this->request->key();

        if ( ! $meta = $this->cache->get($uploadKey)) {
            return $this->response->send(null, HttpResponse::HTTP_GONE);
        }

        $status = $this->verifyPatchRequest($meta);

        if (HttpResponse::HTTP_OK !== $status) {
            return $this->response->send(null, $status);
        }

        $file     = $this->buildFile($meta);
        $checksum = $meta['checksum'];

        try {
            $fileSize = $file->getFileSize();
            $offset   = $file->setKey($uploadKey)->setChecksum($checksum)->upload($fileSize);

            // If upload is done, verify checksum.
            if ($offset === $fileSize) {
                if ( ! $this->verifyChecksum($checksum, $meta['file_path'])) {
                    return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
                }

                $this->event()->dispatch(
                    UploadComplete::NAME,
                    new UploadComplete($file, $this->getRequest(), $this->getResponse())
                );
            } else {
                $this->event()->dispatch(
                    UploadProgress::NAME,
                    new UploadProgress($file, $this->getRequest(), $this->getResponse())
                );
            }
        } catch (FileException $e) {
            return $this->response->send($e->getMessage(), HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
        } catch (OutOfRangeException $e) {
            return $this->response->send(null, HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);
        } catch (ConnectionException $e) {
            return $this->response->send(null, HttpResponse::HTTP_CONTINUE);
        }

        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
            'Content-Type' => self::HEADER_CONTENT_TYPE,
            'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            'Upload-Offset' => $offset,
        ]);
    }
951578
public function downloadable()
    {
        $media = $this->media[0];

        if ($media->disk === 's3') {
            return $media->getTemporaryUrl(new \DateTime('+1 hour'));
        }

        if (in_array($media->disk, ['local', 'public'], true)) {
            return $media->getPath();
        }

        return $media->getFullUrl();
    }
547015
public function download()
    {
        try{
            $this->checkIfTaskIdExists();

            $taskLogEntity = $this->getTaskLogService()->getByIdAndUser(
                $this->getRequestParameter(self::PARAMETER_TASK_ID),
                $this->getSessionUserUri()
            );

            if (!$taskLogEntity->getStatus()->isCompleted()) {
                throw new \common_Exception('Task "'. $taskLogEntity->getId() .'" is not downloadable.');
            }

            $fileNameOrSerial = $taskLogEntity->getFileNameFromReport();

            if (empty($fileNameOrSerial)) {
                throw new \common_Exception('Filename not found in report.');
            }

            // first try to get a referenced file is it is a serial
            $file = $this->getReferencedFile($fileNameOrSerial);

            // if no file let's try the task queue storage
            if (is_null($file)) {
                $file = $this->getQueueStorageFile($fileNameOrSerial);
            }

            if (!$file) {
                throw new \common_exception_NotFound('File not found.');
            }

            header('Set-Cookie: fileDownload=true');
            setcookie('fileDownload', 'true', 0, '/');
            header('Content-Disposition: attachment; filename="' . $file->getBasename() . '"');
            header('Content-Type: ' . $file->getMimeType());

            \tao_helpers_Http::returnStream($file->readPsrStream());
            exit();
        } catch (\Exception $e) {
            return $this->returnJson([
                'success' => false,
                'errorMsg' => $e instanceof \common_exception_UserReadableException ? $e->getUserMessage() : $e->getMessage(),
                'errorCode' => $e->getCode(),
            ]);
        }
    }
108848
public function downloadAction()
	{
		$paths = Base::getAimeos()->getCustomPaths( 'client/html' );
		$context = $this->getContext();
		$view = $context->getView();

		$client = \Aimeos\Client\Html::create( $context, 'account/download' );
		$client->setView( $view );
		$client->process();

		$response = $view->response();
		$this->response->setStatus( $response->getStatusCode() );

		foreach( $response->getHeaders() as $key => $value ) {
			$this->response->setHeader( $key, implode( ', ', $value ) );
		}

		return (string) $response->getBody();
	}
1020630
public function getResponse($id, $filename = null, $forceDownload = false)
	{
		$object = $this->container->get($id);

		if ($filename === null)
		{
			$filename = $object->getBasename();
		}

		if (!pathinfo($filename, PATHINFO_EXTENSION) && $object->getExtension())
		{
			$filename .= '.'. $object->getExtension();
		}

		/** @var HttpResponse $response */
		$response = $this->controller->getResponse();

		$response->setContent(new LazyResponse($object));
		$response->getHeaders()->addHeaders(array(
			'Content-Type' => $object->getContentType() ?: 'application/octet-stream',
			'Content-Disposition' => ($forceDownload ? 'attachment' : 'inline') .';filename="'. str_replace('"', '\\"', $filename) .'"',
			'Content-Transfer-Encoding' => 'binary',
			'Expires' => '-1 year',
			'Cache-Control' => 'must-revalidate',
			'Pragma' => 'public',
			'Content-Length' => $object->getContentLength(),
		));

		return $response;
	}
83925
public function get()
    {
        $response = $this->api->request('GET', $this->containerUrl, [
            'query' => $this->buildParams(),
        ]);

        if ($response->getStatusCode() !== 200) {
            throw new ApiRequestFailedException('Unable to list container files.', $response->getStatusCode());
        }

        $files = json_decode($response->getBody(), true);

        if ($this->asFileObjects === true) {
            $this->asFileObjects = false;

            return $this->getFilesCollectionFromArrays($files);
        }

        // Add 'filename' attribute to each file, so users
        // can pass it to new loader instance as marker,
        // if they want to iterate inside a directory.

        $files = array_map(function ($file) {
            $path = explode('/', $file['name']);
            $file['filename'] = array_pop($path);

            return $file;
        }, $files);

        return new Collection($files);
    }
192979
public function downloadAction($filePath)
    {
        $response = new Response();

        if (!$this->authenticate($filePath)) {
            return $response->setStatusCode(Response::HTTP_UNAUTHORIZED);
        }

        $content = $this->fileSystem->load($filePath);

        $response->headers->set('Content-Type', 'mime/type');
        $response->headers->set('Content-Disposition', 'attachment;filename="' . $filePath);

        $response->setContent($content);

        return $response;
    }
1173804
public function download() {
        // check if the file extension is allowed
        $this->validateExtension();       
        
        // download the file
        $this->downloadFile();
        
        // check the mime type for the file, if it is of the wrong type, unset the
        // file and throw the error on
        try {
            $this->validateFileType();
        } catch (Exception $exception) {
            // remove the file, the mime type is not allowed
            unlink($this->downloadFilePath());
            
            // throw the error on
            throw $exception;
        }

        // everything ok
        return true;
    }
1211305
public function forceDownload()
    {


        if ($this->type == "jpg")

    {
            $this->toJpg();

        } elseif ($this->type == "png") {

            $this->toPng();

        } elseif ($this->type == "gif") {

            $this->toGif();
        }

        header('Content-Description: File Transfer');
        header("Content-Type: application/octet-stream");
        header('Content-Length: ' . filesize($this->path));
        header('Content-Disposition: attachment; filename="' . basename($this->path.'"'));
        readfile($this->path);

        //remove the temp file
        unlink($this->path);

    }
605642
public function downloadAction()
	{
		$response = $this->container->get( 'shop' )->get( 'account/download' )->getView()->response();
		return Response::create( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() );
	}
663239
public function downloadAction()
	{
		$response = Shop::get( 'account/download' )->getView()->response();
		return Response::make( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() );
	}
499505
public function release()
    {
        $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'release');

        $response = $this->httpRequest($path, Requests::POST, []);

        return $this->populate($response);
    }