Allow for upload/download from/to memory

Useful if files are accessed rarely and should not be saved to avoid I/O bottleneck
This commit is contained in:
andynazay153 2018-06-12 19:46:33 -07:00 committed by GitHub
parent 26d1b68f84
commit 88c6b54b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -258,11 +258,16 @@ class SpacesConnect {
if($access == "public") {
$access = "public-read";
}
if(!is_file($pathToFile)){
$file = $pathToFile;
}else{
$file = fopen($pathToFile, 'r+');
}
try {
$result = $this->client->putObject(array(
'Bucket' => $this->space,
'Key' => $save_as,
'Body' => fopen($pathToFile, 'r+'),
'Body' => $file,
"ACL" => $access
));
@ -281,7 +286,7 @@ class SpacesConnect {
/*
Download a file.
*/
function DownloadFile($fileName, $destinationPath) {
function DownloadFile($fileName, $destinationPath = false) {
try {
$result = $this->client->getObject(array(
'Bucket' => $this->space,
@ -289,6 +294,10 @@ class SpacesConnect {
'SaveAs' => $destinationPath
));
if(!$destinationPath) {
return $result;
}
return $this->ObjReturn($result->toArray());
}
catch (\Exception $e) {