From 20cdaf2c530701e6bb08243fe4e4ed4d466d8866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Carretero?= <frederic.carretero@veremes.com> Date: Thu, 22 Nov 2018 09:47:44 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9chargement=20d'un=20fichier=20dan?= =?UTF-8?q?s=20le=20r=C3=A9pertoire=20d'un=20projet=20FME=20sur=20S3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_service/ws/Workspaces.class.inc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/web_service/ws/Workspaces.class.inc b/web_service/ws/Workspaces.class.inc index 0f342563..25df9f32 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."); } /** -- GitLab