diff --git a/spaces.php b/spaces.php index 806c2a9..9cd6a76 100644 --- a/spaces.php +++ b/spaces.php @@ -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,13 +286,17 @@ class SpacesConnect { /* Download a file. */ - function DownloadFile($fileName, $destinationPath) { + function DownloadFile($fileName, $destinationPath = false) { try { $result = $this->client->getObject(array( 'Bucket' => $this->space, 'Key' => $fileName, 'SaveAs' => $destinationPath )); + + if(!$destinationPath) { + return $result; + } return $this->ObjReturn($result->toArray()); }