diff --git a/web_service/ws/Workspaces.class.inc b/web_service/ws/Workspaces.class.inc index 0f342563f423b975c9cb3c384650c9dbb90cc98b..25df9f3208b56314499b2c1e23724764a11aab75 100755 --- a/web_service/ws/Workspaces.class.inc +++ b/web_service/ws/Workspaces.class.inc @@ -1194,16 +1194,26 @@ class Workspaces extends GTF { * Get workspace file. */ function getWorkspaceFile() { - $aReturn = array('status' => 1, 'message' => ''); - $sFilePath = $this->aProperties['workspace_dir'] . '/' . $this->aValues["my_vitis_id"] . '/fme/' . $this->aValues['file_name']; - // Le fichier existe ? - if (file_exists($sFilePath)) { + // Chargement du contenu du fichier. + $sFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $this->aValues['file_name']); + if ($sFileContent !== false) { + // Copie du fichier dans un répertoire temporaire. + $sFilePath = $this->aProperties['extract_dir'] . '/' . getUniqRandomId() . '/' . $this->aValues['file_name']; + $sFileDirPath = pathinfo($sFilePath, PATHINFO_DIRNAME); + if (file_exists($sFileDirPath)) + cleardir($sFileDirPath); + mkdir($sFileDirPath, 0777, true); + file_put_contents($sFilePath, $sFileContent); + // Retourne les entêtes pour forcer le téléchargement du fichier. header("Content-Type: application/octet-stream"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" . $this->aValues['file_name'] . "\""); header('Content-Length: ' . filesize($sFilePath)); readfile($sFilePath); + cleardir($sFileDirPath); } + else + WriteToErrorLog("The file '$sWidgetFile' does not exist."); } /**