IssueFileManager::downloadFile PHP Method

downloadFile() public method

Download a file.
public downloadFile ( $fileId, $inline = false ) : boolean
$fileId int the file id of the file to download
$inline print file as inline instead of attachment, optional
return boolean
    function downloadFile($fileId, $inline = false)
    {
        $issueFileDao = DAORegistry::getDAO('IssueFileDAO');
        $issueFile = $issueFileDao->getById($fileId);
        if ($issueFile) {
            $fileType = $issueFile->getFileType();
            $filePath = $this->getFilesDir() . $this->contentTypeToPath($issueFile->getContentType()) . '/' . $issueFile->getServerFileName();
            return parent::downloadFile($filePath, $fileType, $inline);
        } else {
            return false;
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * An action to download an issue galley
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function download($args, $request)
 {
     $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
     $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
     import('classes.file.IssueFileManager');
     $issueFileManager = new IssueFileManager($issue->getId());
     return $issueFileManager->downloadFile($issueGalley->getFileId());
 }
All Usage Examples Of IssueFileManager::downloadFile