diff --git a/web_service/ws/Workspaces.class.inc b/web_service/ws/Workspaces.class.inc index 1c01ecbbc2d06e0e60af01e68471902221a2d81b..5bd38768a1ed2fcce80e069577856de1d98c07e5 100755 --- a/web_service/ws/Workspaces.class.inc +++ b/web_service/ws/Workspaces.class.inc @@ -527,23 +527,33 @@ class Workspaces extends GTF { } */ } - $oFmwParser = new GtfFmwParser($sDirName . "/fme/" . $_FILES['fmw_file']['name']); + // Télécharge le fichier .fmw qui est sur S3. + if ($this->aProperties['fileS3Uploader'] === true) { + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $_FILES['fmw_file']['name']); + if ($sFmwFileContent !== false) { + $sFmwFilePath = $this->aProperties['extract_dir'] . '/' . getUniqRandomId() . '/' . $_FILES['fmw_file']['name']; + mkdir(pathinfo($sFmwFilePath, PATHINFO_DIRNAME)); + file_put_contents($sFmwFilePath, $sFmwFileContent); + } + } + else + $sFmwFilePath = $sDirName . "/fme/" . $_FILES['fmw_file']['name']; // Sauve le .fmw sans les visualizers. - $oFmwParser->save($sDirName . "/fme/" . utf8_decode($_FILES['fmw_file']['name'])); + $oFmwParser = new GtfFmwParser($sFmwFilePath); + $oFmwParser->save($sFmwFilePath); + // Sauve le fichier sur S3. + if ($this->aProperties['fileS3Uploader'] === true) + putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'fme', $_FILES['fmw_file']['name'], file_get_contents($sFmwFilePath)); // Création des formulaires json. $aJson = $oFmwParser->productJson($this->aProperties, $oWorkspace->aFields["name"]); - $fJson = fopen($sDirName . "/form/Subform.json", "w+"); - if (fwrite($fJson, json_encode($aJson)) == FALSE) { - if ($fJson == FALSE) { - writeToErrorLog("Subform.json can't be opened : " . $sDirName . "/form/ressources/Subform.json" . "(Workspaces.class.inc : verify the property workspace_dir)"); - } else { - writeToErrorLog("Subform.json can't be writed : " . $sDirName . "/form/ressources/Subform.json" . "(Workspaces.class.inc : verify the folder's rights)"); - } + if (putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form', 'Subform.json', json_encode($aJson)) !== false) { + copyFileInWsDataDir ('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form', 'Subform.json', 'WSubform.json'); + copyFileInWsDataDir ('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form', 'Subform.json', 'DSubform.json'); } - fclose($fJson); - copy($sDirName . "/form/Subform.json", $sDirName . "/form/WSubform.json"); - copy($sDirName . "/form/Subform.json", $sDirName . "/form/DSubform.json"); $oFmwParser->updateMetadata($this->oConnection->oBd, $oWorkspace->aFields["workspace_id"]); + // Supprime le fichier .fmw temporaire. + if ($this->aProperties['fileS3Uploader'] === true) + clearDir(pathinfo($sFmwFilePath, PATHINFO_DIRNAME)); /* * ************************************************************** */ } else { writeToErrorLog("the uploaded file is not a fmw file or no file uploaded (Workspaces.class.inc : user_id->" . $_SESSION["user_id"] . ")");