Public perms on file copy/move will now retain the current value

This commit is contained in:
David Wakelin 2022-02-08 18:16:12 +00:00
commit 591d0be758

View file

@ -4,6 +4,8 @@ namespace SpacesAPI;
use SpacesAPI\Exceptions\FileDoesntExistException; use SpacesAPI\Exceptions\FileDoesntExistException;
use function PHPUnit\Framework\isNull;
/** /**
* Represents a single file * Represents a single file
* *
@ -211,14 +213,14 @@ class File
* *
* @return \SpacesAPI\File * @return \SpacesAPI\File
*/ */
public function copy(string $newFilename, bool $public = false): File public function copy(string $newFilename): File
{ {
$this->s3->copy( $this->s3->copy(
$this->space_name, $this->space_name,
$this->_filename, $this->_filename,
$this->space_name, $this->space_name,
$newFilename, $newFilename,
($public) ? 'public-read' : 'private' ($this->isPublic()) ? 'public-read' : 'private'
); );
return new self($this->space, $newFilename); return new self($this->space, $newFilename);
@ -231,7 +233,7 @@ class File
*/ */
public function move(string $newFilename): File public function move(string $newFilename): File
{ {
$newFile = $this->copy($newFilename, $this->isPublic()); $newFile = $this->copy($newFilename);
$this->delete(); $this->delete();
return $newFile; return $newFile;