diff --git a/vas/rest/class/vmlib/files/S3_files.class.inc b/vas/rest/class/vmlib/files/S3_files.class.inc index 76fee87b14586e95b6e0fdaece92fa5f6947714e..ead65c2a01d43903530db35c414cbc3a23a55c1c 100644 --- a/vas/rest/class/vmlib/files/S3_files.class.inc +++ b/vas/rest/class/vmlib/files/S3_files.class.inc @@ -51,6 +51,9 @@ class S3_files implements Files{ public function getFileEtag($sFilePath){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try { $oResult = $this->oS3Client->headObject(array( @@ -73,6 +76,9 @@ class S3_files implements Files{ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try { $this->oS3Client->headObject(array( @@ -96,6 +102,9 @@ class S3_files implements Files{ public function file_put_contents ($sFilePath, $sData, $iFlags = 0, $mContext = null){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try { $this->oS3Client->putObject(array( @@ -123,6 +132,9 @@ class S3_files implements Files{ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); $sPath = $this->oProperties['extract_dir'] . "/" . getUniqRandomId(); @@ -161,6 +173,9 @@ class S3_files implements Files{ public function file_get_contents_with_etag ($sFilePath, $sEtag ,$bUseIncludePath = FALSE, $mContext = null, $iOffset = 0, $iMaxLen = -1){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); $sPath = $this->oProperties['extract_dir'] . "/" . getUniqRandomId(); @@ -196,7 +211,12 @@ class S3_files implements Files{ list($sBucket, $sPrefix) = $this->getBucketConst(); $sDestFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sDestFilePath); $sSourceFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sSourceFilePath); - + // Suppression du slash de début de ligne. + if (strpos($sDestFilePath, '/') === 0) + $sDestFilePath = substr($sDestFilePath, 1); + if (strpos($sSourceFilePath, '/') === 0) + $sSourceFilePath = substr($sSourceFilePath, 1); + // try{ $this->oS3Client->copyObject(array( 'Bucket' => $sBucket, @@ -219,6 +239,11 @@ class S3_files implements Files{ public function copyInAnotherBucket ($sSourceFilePath, $sDests3Key, $sDestBucket){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sSourceFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sSourceFilePath); + // Suppression du slash de début de ligne. + if (strpos($sSourceFilePath, '/') === 0) + $sSourceFilePath = substr($sSourceFilePath, 1); + if (strpos($sDests3Key, '/') === 0) + $sDests3Key = substr($sDests3Key, 1); try{ $this->oS3Client->copyObject(array( @@ -241,6 +266,9 @@ class S3_files implements Files{ public function copyLocalToS3 ($sSourceFilePath, $sDestFilePath){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sDestFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sDestFilePath); + // Suppression du slash de début de ligne. + if (strpos($sDestFilePath, '/') === 0) + $sDestFilePath = substr($sDestFilePath, 1); try { $this->oS3Client->putObject(array( @@ -263,6 +291,9 @@ class S3_files implements Files{ public function filesize ($sFilePath){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try { $oResult = $this->oS3Client->headObject(array( @@ -286,6 +317,9 @@ class S3_files implements Files{ public function readfile ($sFilePath, $bUseIncludePath = FALSE, $mContext = null){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); $sPath = $this->oProperties['extract_dir'] . "/" . getUniqRandomId(); @@ -327,6 +361,9 @@ class S3_files implements Files{ public function unlink ($sFilePath, $mContext = null){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try{ $this->oS3Client->deleteObject(array( @@ -347,6 +384,9 @@ class S3_files implements Files{ public function filemtime ($sFilePath){ list($sBucket, $sPrefix) = $this->getBucketConst(); $sFilePath = str_replace($this->oProperties["vas_home"], $sPrefix , $sFilePath); + // Suppression du slash de début de ligne. + if (strpos($sFilePath, '/') === 0) + $sFilePath = substr($sFilePath, 1); try { $oResult = $this->oS3Client->headObject(array( diff --git a/vas/rest/class/vmlib/phpUtil.inc b/vas/rest/class/vmlib/phpUtil.inc index 3d4bcb04cb3dedb23be91097f68d0bf9c698da89..bac8eeaa4c6aa6df98f4dbe63d60bc5e1272b968 100755 --- a/vas/rest/class/vmlib/phpUtil.inc +++ b/vas/rest/class/vmlib/phpUtil.inc @@ -131,7 +131,7 @@ function stripslashes_deep($aString) { //Lance l'upload. if ($bAllowUpload) { - if ($properties['fileS3Uploader']){ + if ($properties['filesystem'] == 's3'){ require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( @@ -413,7 +413,7 @@ function stripslashes_deep($aString) { $sScanDir .= "/" . $sField; } - if ($properties['fileS3Uploader']){ + if ($properties['filesystem'] == 's3'){ return array(getS3FolderInfos($sScanDir)); }else{ return array(getFolderInfos($sScanDir)); @@ -433,7 +433,7 @@ function stripslashes_deep($aString) { require_once ("aws_sdk/aws-autoloader.php"); $sFilePath = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId . "/" . $sField . "/" . $sFilePath; - if ($properties['fileS3Uploader']){ + if ($properties['filesystem'] == 's3'){ // traitement du bucket et de ses sous-dossiers $sBucket = $properties['fileS3UploaderBucket']; $sPrefix = ""; @@ -491,7 +491,7 @@ function stripslashes_deep($aString) { $aFileStruct = extractFileStruct ($sAttrName, $aValues); - if ($properties['fileS3Uploader']){ + if ($properties['filesystem'] == 's3'){ // traitement du bucket et de ses sous-dossiers $sBucket = $properties['fileS3UploaderBucket']; $sPrefix = ""; @@ -1414,7 +1414,7 @@ function copyFileInWsDataDir ($sModule, $sObject, $mId, $sField = '', $sFileName $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1471,7 +1471,7 @@ function deleteDirectoryInWsDataDir($sModule, $sObject, $mId, $sField = '', $sDi $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1543,7 +1543,7 @@ function getFileContentInWsDataDir($sModule, $sObject, $mId, $sField = '', $sFil $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1611,7 +1611,7 @@ function putFileContentInWsDataDir($sModule, $sObject, $mId = '', $sField = '', $sDestDir .= "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1682,7 +1682,7 @@ function isDirInWsDataDir($sModule, $sObject, $mId, $sDirectoryName = '') { $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if (!empty($sDirectoryName)) $sDestDir .= '/' . $sDirectoryName; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1743,7 +1743,7 @@ function fileExistsInWsDataDir($sModule, $sObject, $mId = '', $sDirectory = '', $sDestDir .= "/" . $mId; if(!empty($sDirectory)) $sDestDir .= "/" . $sDirectory; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -1802,7 +1802,7 @@ function getFileUrlInWsDataDir($sModule, $sObject, $mId, $sField = '', $sFileNam $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest', @@ -2010,7 +2010,7 @@ function unzipInWsDataDir($sModule, $sObject, $mId, $sField = '', $sZipFilePath) $sDestDir = $properties['ws_data_dir'] . "/" . $sModule . "/" . $sObject . "/" . $mId; if(!empty($sField)) $sDestDir .= "/" . $sField; - if ($properties['fileS3Uploader'] === true) { + if ($properties['filesystem'] == 's3') { require_once ("aws_sdk/aws-autoloader.php"); $s3 = new Aws\S3\S3Client(array( 'version'=>'latest',