src/DataService/DataService.php
protected function processDownloadedContent(ContentWriter $writer, $responseCode, $fileName = null, $dir)
    {
        $writer->setPrefix($this->getPrefixFromSettings());
        try {
            if(isset($dir) && !empty($dir)){
                $writer->saveFile($dir, $fileName);
            }else if ($this->isTempFile()) {
                $writer->saveTemp();
            } elseif ($this->isFileExport()) {
                $writer->saveFile($this->getFileExportDir(), $fileName);
            } else {
                $writer->saveAsHandler();
            }
            //return object as is
            if ($this->isReturnContentWriter()) {
                return $writer;
            }
            $writer->resetContent();
            $this->logInfo("File was downloaded (http response = $responseCode), bytes written: {$writer->getBytes()}");
        } catch (\Exception $ex) {
            $this->logError("Exception appears during response processing. Http response was $responseCode: " . $ex->getMessage() . "\n" . $ex->getTraceAsString());

            return null;
        }

        return $writer->isHandler() ? $writer->getHandler() : $writer->getTempPath();
    }
protected function processDownloadedContent(ContentWriter $writer, $responseCode, $fileName = null, $dir)
    {
        $writer->setPrefix($this->getPrefixFromSettings());
        try {
            if(isset($dir) && !empty($dir)){
                $writer->saveFile($dir, $fileName);
            }else if ($this->isTempFile()) {
                $writer->saveTemp();
            } elseif ($this->isFileExport()) {
                $writer->saveFile($this->getFileExportDir(), $fileName);
            } else {
                $writer->saveAsHandler();
            }
            //return object as is
            if ($this->isReturnContentWriter()) {
                return $writer;
            }
            $writer->resetContent();
            $this->logInfo("File was downloaded (http response = $responseCode), bytes written: {$writer->getBytes()}");
        } catch (\Exception $ex) {
            $this->logError("Exception appears during response processing. Http response was $responseCode: " . $ex->getMessage() . "\n" . $ex->getTraceAsString());

            return null;
        }

        return $writer->isHandler() ? $writer->getHandler() : $writer->getTempPath();
    }
Saves exported (e.g. check DownloadPDF) entity into file according to strategy in settings
@param ContentWriter $writer
@param int $responseCode
@param string $fileName
@return mixed full path with filename or open handler