Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vMap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marty Fabien
vMap
Commits
ed012e6d
Commit
ed012e6d
authored
Dec 4, 2018
by
Anthony Borghi
Browse files
Options
Downloads
Patches
Plain Diff
commentaires sur les classes interfaces fichiers
parent
9be95c89
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/vitis/vas/rest/class/vmlib/files/Local_files.class.inc
+71
-1
71 additions, 1 deletion
src/vitis/vas/rest/class/vmlib/files/Local_files.class.inc
src/vitis/vas/rest/class/vmlib/files/S3_files.class.inc
+107
-4
107 additions, 4 deletions
src/vitis/vas/rest/class/vmlib/files/S3_files.class.inc
with
178 additions
and
5 deletions
src/vitis/vas/rest/class/vmlib/files/Local_files.class.inc
+
71
−
1
View file @
ed012e6d
...
@@ -43,6 +43,15 @@ class Local_files implements Files{
...
@@ -43,6 +43,15 @@ class Local_files implements Files{
public
function
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
=
0
,
$mContext
=
null
){
public
function
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
=
0
,
$mContext
=
null
){
return
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
,
$mContext
);
return
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
,
$mContext
);
}
}
/**
*read a file and return content in a string.
*@param string $sFilePath File's path.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@param integer $iOffset offset in bytes to begin file reading, Default : 0.
*@param integer $iMaxLen Number of byte to read from the file, Default : -1 = read until the file's end.
*@return string|boolean file content, or false if the process encounter an error.
*/
public
function
file_get_contents
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
public
function
file_get_contents
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
if
(
$iMaxLen
==
-
1
){
if
(
$iMaxLen
==
-
1
){
return
file_get_contents
(
$sFilePath
,
$bUseIncludePath
,
null
,
$iOffset
);
return
file_get_contents
(
$sFilePath
,
$bUseIncludePath
,
null
,
$iOffset
);
...
@@ -50,6 +59,16 @@ class Local_files implements Files{
...
@@ -50,6 +59,16 @@ class Local_files implements Files{
return
file_get_contents
(
$sFilePath
,
$bUseIncludePath
,
null
,
$iOffset
,
$iMaxLen
);
return
file_get_contents
(
$sFilePath
,
$bUseIncludePath
,
null
,
$iOffset
,
$iMaxLen
);
}
}
}
}
/**
*read a file and return content in a string if eTag matches.
*@param string $sFilePath File's path.
*@param string $sEtag Hash Sha1 of file's content.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@param integer $iOffset offset in bytes to begin file reading, Default : 0.
*@param integer $iMaxLen Number of byte to read from the file, Default : -1 = read until the file's end.
*@return string|boolean file content, or false if the process encounter an error.
*/
public
function
file_get_contents_with_etag
(
$sFilePath
,
$sEtag
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
public
function
file_get_contents_with_etag
(
$sFilePath
,
$sEtag
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
$sProcessedEtag
=
$this
->
getFileEtag
(
$sFilePath
);
$sProcessedEtag
=
$this
->
getFileEtag
(
$sFilePath
);
if
(
$sEtag
==
$sProcessedEtag
){
if
(
$sEtag
==
$sProcessedEtag
){
...
@@ -58,15 +77,40 @@ class Local_files implements Files{
...
@@ -58,15 +77,40 @@ class Local_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*copy a file.
*@param string $sSourceFilePath File's path to copy.
*@param string $sDestFilePath File's destination.
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
copy
(
$sSourceFilePath
,
$sDestFilePath
){
public
function
copy
(
$sSourceFilePath
,
$sDestFilePath
){
return
copy
(
$sSourceFilePath
,
$sDestFilePath
);
return
copy
(
$sSourceFilePath
,
$sDestFilePath
);
}
}
/**
*return the size of a file in bytes.
*@param string $sFilePath File's path.
*@return integer|boolean File's size in bytes or false if the process encounter an error.
*/
public
function
filesize
(
$sFilePath
){
public
function
filesize
(
$sFilePath
){
return
filesize
(
$sFilePath
);
return
filesize
(
$sFilePath
);
}
}
/**
*send file's content into stdout.
*@param string $sFilePath File's path.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@return integer|boolean File's size in bytes or false if the process encounter an error.
*/
public
function
readfile
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
){
public
function
readfile
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
){
return
readfile
(
$sFilePath
,
$bUseIncludePath
,
$mContext
);
return
readfile
(
$sFilePath
,
$bUseIncludePath
,
$mContext
);
}
}
/**
*move a file.
*@param string $sSourceFilePath File's path to copy.
*@param string $sDestFilePath File's destination.
*@param resource $mContext result de stream_context_create().
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
=
null
){
public
function
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
=
null
){
if
(
empty
(
$mContext
)){
if
(
empty
(
$mContext
)){
return
rename
(
$sSourceFilePath
,
$sDestFilePath
);
return
rename
(
$sSourceFilePath
,
$sDestFilePath
);
...
@@ -74,6 +118,12 @@ class Local_files implements Files{
...
@@ -74,6 +118,12 @@ class Local_files implements Files{
return
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
);
return
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
);
}
}
}
}
/**
*remove a file.
*@param string $sFilePath File's path.
*@param resource $mContext result de stream_context_create().
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
unlink
(
$sFilePath
,
$mContext
=
null
){
public
function
unlink
(
$sFilePath
,
$mContext
=
null
){
if
(
empty
(
$mContext
)){
if
(
empty
(
$mContext
)){
return
unlink
(
$sFilePath
);
return
unlink
(
$sFilePath
);
...
@@ -81,13 +131,28 @@ class Local_files implements Files{
...
@@ -81,13 +131,28 @@ class Local_files implements Files{
return
unlink
(
$sFilePath
,
$mContext
);
return
unlink
(
$sFilePath
,
$mContext
);
}
}
}
}
/**
*return the number of second UNIX of the last modification on a file.
*@param string $sFilePath File's path.
*@return integer|boolean timestamp on sucess or false if the process encounter an error.
*/
public
function
filemtime
(
$sFilePath
){
public
function
filemtime
(
$sFilePath
){
return
filemtime
(
$sFilePath
);
return
filemtime
(
$sFilePath
);
}
}
/**
*return the fomrated date of the last modification on a file.
*@param string $sFilePath File's path.
*@param string $sFormat Format to convert the timestamp.
*@return string|boolean date string on sucess or false if the process encounter an error.
*/
public
function
filemtime_formated
(
$sFilePath
,
$sFormat
){
public
function
filemtime_formated
(
$sFilePath
,
$sFormat
){
return
date
(
$sFormat
,
$this
->
filemtime
(
$sFilePath
));
return
date
(
$sFormat
,
$this
->
filemtime
(
$sFilePath
));
}
}
/**
*return the metadata structure of a file.
*@param string $sFilePath File's path.
*@return array filename, size, lastModification, href.
*/
public
function
getFileInfos
(
$sFilePath
){
public
function
getFileInfos
(
$sFilePath
){
$iFileSize
=
$this
->
filesize
(
$sFilePath
);
$iFileSize
=
$this
->
filesize
(
$sFilePath
);
...
@@ -108,6 +173,11 @@ class Local_files implements Files{
...
@@ -108,6 +173,11 @@ class Local_files implements Files{
return
array
(
"filename"
=>
$aFileName
[
count
(
$aFileName
)
-
1
],
"size"
=>
$sFileSize
,
"lastModification"
=>
$this
->
filemtime_formated
(
$sFilePath
,
"d/m/Y H:i:s"
),
"href"
=>
$this
->
getProxyPassUrl
(
$sFilePath
));
return
array
(
"filename"
=>
$aFileName
[
count
(
$aFileName
)
-
1
],
"size"
=>
$sFileSize
,
"lastModification"
=>
$this
->
filemtime_formated
(
$sFilePath
,
"d/m/Y H:i:s"
),
"href"
=>
$this
->
getProxyPassUrl
(
$sFilePath
));
}
}
/**
*return an url to download the file through Vitis API .
*@param string $sFilePath File's path.
*@return string url.
*/
public
function
getProxyPassUrl
(
$sFilePath
){
public
function
getProxyPassUrl
(
$sFilePath
){
$date
=
new
DateTime
();
$date
=
new
DateTime
();
$sDataUrl
=
$this
->
oProperties
[
'web_server_name'
]
.
"/rest/vitis/file_downloader?key=[KEY]&eTag=[ETAG]&d="
.
$date
->
getTimestamp
();
$sDataUrl
=
$this
->
oProperties
[
'web_server_name'
]
.
"/rest/vitis/file_downloader?key=[KEY]&eTag=[ETAG]&d="
.
$date
->
getTimestamp
();
...
...
This diff is collapsed.
Click to expand it.
src/vitis/vas/rest/class/vmlib/files/S3_files.class.inc
+
107
−
4
View file @
ed012e6d
...
@@ -20,7 +20,11 @@ class S3_files implements Files{
...
@@ -20,7 +20,11 @@ class S3_files implements Files{
'debug'
=>
false
'debug'
=>
false
));
));
}
}
/**
*parse vitis properties ti extract bucket name and bucket prefix.
*@private
*@return array bucket'name, prefix.
*/
private
function
getBucketConst
(){
private
function
getBucketConst
(){
$sBucket
=
$this
->
oProperties
[
'fileS3UploaderBucket'
];
$sBucket
=
$this
->
oProperties
[
'fileS3UploaderBucket'
];
$sPrefix
=
""
;
$sPrefix
=
""
;
...
@@ -33,6 +37,11 @@ class S3_files implements Files{
...
@@ -33,6 +37,11 @@ class S3_files implements Files{
return
array
(
$sBucket
,
$sPrefix
);
return
array
(
$sBucket
,
$sPrefix
);
}
}
/**
*This method return the extension of a file.
*@param string $sFilePath File's path.
*@return string|boolean hash md5 of file content or false if the file doesn't exist.
*/
public
function
getFileEtag
(
$sFilePath
){
public
function
getFileEtag
(
$sFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -49,6 +58,11 @@ class S3_files implements Files{
...
@@ -49,6 +58,11 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*verify if a file exists.
*@param string $sFilePath File's path.
*@return boolean true if file exists, false else.
*/
public
function
file_exists
(
$sFilePath
){
public
function
file_exists
(
$sFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
...
@@ -65,6 +79,14 @@ class S3_files implements Files{
...
@@ -65,6 +79,14 @@ class S3_files implements Files{
}
}
return
true
;
return
true
;
}
}
/**
*Write a string in a file.
*@param string $sFilePath File's path.
*@param string $sData string to write in this file.
*@param integer $iFlags flags to write in file (http://php.net/manual/fr/function.file-put-contents.php) Default : 0.
*@param resource $mContext result de stream_context_create().
*@return integer|boolean number of byte written, or false if the process encounter an error.
*/
public
function
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
=
0
,
$mContext
=
null
){
public
function
file_put_contents
(
$sFilePath
,
$sData
,
$iFlags
=
0
,
$mContext
=
null
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -82,7 +104,15 @@ class S3_files implements Files{
...
@@ -82,7 +104,15 @@ class S3_files implements Files{
}
}
return
strlen
(
$sData
);
return
strlen
(
$sData
);
}
}
/**
*read a file and return content in a string.
*@param string $sFilePath File's path.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@param integer $iOffset offset in bytes to begin file reading, Default : 0.
*@param integer $iMaxLen Number of byte to read from the file, Default : -1 = read until the file's end.
*@return string|boolean file content, or false if the process encounter an error.
*/
public
function
file_get_contents
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
public
function
file_get_contents
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
...
@@ -112,7 +142,16 @@ class S3_files implements Files{
...
@@ -112,7 +142,16 @@ class S3_files implements Files{
unlink
(
$sPath
);
unlink
(
$sPath
);
return
$sFile
;
return
$sFile
;
}
}
/**
*read a file and return content in a string if eTag matches.
*@param string $sFilePath File's path.
*@param string $sEtag Hash Sha1 of file's content.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@param integer $iOffset offset in bytes to begin file reading, Default : 0.
*@param integer $iMaxLen Number of byte to read from the file, Default : -1 = read until the file's end.
*@return string|boolean file content, or false if the process encounter an error.
*/
public
function
file_get_contents_with_etag
(
$sFilePath
,
$sEtag
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
public
function
file_get_contents_with_etag
(
$sFilePath
,
$sEtag
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
,
$iOffset
=
0
,
$iMaxLen
=
-
1
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -141,7 +180,12 @@ class S3_files implements Files{
...
@@ -141,7 +180,12 @@ class S3_files implements Files{
unlink
(
$sPath
);
unlink
(
$sPath
);
return
$sFile
;
return
$sFile
;
}
}
/**
*copy a file in the same bucket.
*@param string $sSourceFilePath Object's key to copy.
*@param string $sDestFilePath Object's destination key.
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
copy
(
$sSourceFilePath
,
$sDestFilePath
){
public
function
copy
(
$sSourceFilePath
,
$sDestFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sDestFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sDestFilePath
);
$sDestFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sDestFilePath
);
...
@@ -159,6 +203,13 @@ class S3_files implements Files{
...
@@ -159,6 +203,13 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*copy a file in another bucket.
*@param string $sSourceFilePath Object's key to copy.
*@param string $sDests3Key Object's destination key.
*@param string $sDestBucket Object's destination bucket.
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
copyInAnotherBucket
(
$sSourceFilePath
,
$sDests3Key
,
$sDestBucket
){
public
function
copyInAnotherBucket
(
$sSourceFilePath
,
$sDests3Key
,
$sDestBucket
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sSourceFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sSourceFilePath
);
$sSourceFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sSourceFilePath
);
...
@@ -175,6 +226,12 @@ class S3_files implements Files{
...
@@ -175,6 +226,12 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*send a local file to S3.
*@param string $sSourceFilePath File's path to copy.
*@param string $sDestFilePath Object's destination key.
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
copyLocalToS3
(
$sSourceFilePath
,
$sDestFilePath
){
public
function
copyLocalToS3
(
$sSourceFilePath
,
$sDestFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sDestFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sDestFilePath
);
$sDestFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sDestFilePath
);
...
@@ -192,6 +249,11 @@ class S3_files implements Files{
...
@@ -192,6 +249,11 @@ class S3_files implements Files{
}
}
return
true
;
return
true
;
}
}
/**
*return the size of a file in bytes.
*@param string $sFilePath File's path.
*@return integer|boolean File's size in bytes or false if the process encounter an error.
*/
public
function
filesize
(
$sFilePath
){
public
function
filesize
(
$sFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -208,6 +270,13 @@ class S3_files implements Files{
...
@@ -208,6 +270,13 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*send file's content into stdout.
*@param string $sFilePath File's path.
*@param boolean $bUseIncludePath use include var to resolve a relative path.
*@param resource $mContext result de stream_context_create().
*@return integer|boolean File's size in bytes or false if the process encounter an error.
*/
public
function
readfile
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
){
public
function
readfile
(
$sFilePath
,
$bUseIncludePath
=
FALSE
,
$mContext
=
null
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -230,12 +299,25 @@ class S3_files implements Files{
...
@@ -230,12 +299,25 @@ class S3_files implements Files{
unlink
(
$sPath
);
unlink
(
$sPath
);
return
$iLength
;
return
$iLength
;
}
}
/**
*move a file.
*@param string $sSourceFilePath File's path to copy.
*@param string $sDestFilePath File's destination.
*@param resource $mContext result de stream_context_create().
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
=
null
){
public
function
rename
(
$sSourceFilePath
,
$sDestFilePath
,
$mContext
=
null
){
$bReturn
=
$this
->
copy
(
$sSourceFilePath
,
$sDestFilePath
);
$bReturn
=
$this
->
copy
(
$sSourceFilePath
,
$sDestFilePath
);
if
(
$bReturn
)
if
(
$bReturn
)
$bReturn
=
$this
->
unlink
(
$sSourceFilePath
,
$mContext
);
$bReturn
=
$this
->
unlink
(
$sSourceFilePath
,
$mContext
);
return
$bReturn
;
return
$bReturn
;
}
}
/**
*remove a file.
*@param string $sFilePath File's path.
*@param resource $mContext result de stream_context_create().
*@return boolean true on sucess or false if the process encounter an error.
*/
public
function
unlink
(
$sFilePath
,
$mContext
=
null
){
public
function
unlink
(
$sFilePath
,
$mContext
=
null
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -251,6 +333,11 @@ class S3_files implements Files{
...
@@ -251,6 +333,11 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*return the number of second UNIX of the last modification on a file.
*@param string $sFilePath File's path.
*@return integer|boolean timestamp on sucess or false if the process encounter an error.
*/
public
function
filemtime
(
$sFilePath
){
public
function
filemtime
(
$sFilePath
){
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
$sFilePath
=
str_replace
(
$this
->
oProperties
[
"vas_home"
],
$sPrefix
,
$sFilePath
);
...
@@ -267,9 +354,20 @@ class S3_files implements Files{
...
@@ -267,9 +354,20 @@ class S3_files implements Files{
return
false
;
return
false
;
}
}
}
}
/**
*return the fomrated date of the last modification on a file.
*@param string $sFilePath File's path.
*@param string $sFormat Format to convert the timestamp.
*@return string|boolean date string on sucess or false if the process encounter an error.
*/
public
function
filemtime_formated
(
$sFilePath
,
$sFormat
){
public
function
filemtime_formated
(
$sFilePath
,
$sFormat
){
return
date
(
$sFormat
,
$this
->
filemtime
(
$sFilePath
));
return
date
(
$sFormat
,
$this
->
filemtime
(
$sFilePath
));
}
}
/**
*return the metadata structure of a file.
*@param string $sFilePath File's path.
*@return array filename, size, lastModification, href.
*/
public
function
getFileInfos
(
$sFilePath
){
public
function
getFileInfos
(
$sFilePath
){
$iFileSize
=
$this
->
filesize
(
$sFilePath
);
$iFileSize
=
$this
->
filesize
(
$sFilePath
);
...
@@ -290,6 +388,11 @@ class S3_files implements Files{
...
@@ -290,6 +388,11 @@ class S3_files implements Files{
return
array
(
"filename"
=>
$aFileName
[
count
(
$aFileName
)
-
1
],
"size"
=>
$sFileSize
,
"lastModification"
=>
$this
->
filemtime_formated
(
$sFilePath
,
"d/m/Y H:i:s"
),
"href"
=>
$this
->
getProxyPassUrl
(
$sFilePath
));
return
array
(
"filename"
=>
$aFileName
[
count
(
$aFileName
)
-
1
],
"size"
=>
$sFileSize
,
"lastModification"
=>
$this
->
filemtime_formated
(
$sFilePath
,
"d/m/Y H:i:s"
),
"href"
=>
$this
->
getProxyPassUrl
(
$sFilePath
));
}
}
/**
*return an url to download the file through Vitis API .
*@param string $sFilePath File's path.
*@return string url.
*/
public
function
getProxyPassUrl
(
$sFilePath
){
public
function
getProxyPassUrl
(
$sFilePath
){
$sEtag
=
$this
->
getFileEtag
(
$sFilePath
);
$sEtag
=
$this
->
getFileEtag
(
$sFilePath
);
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
list
(
$sBucket
,
$sPrefix
)
=
$this
->
getBucketConst
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment