Skip to content

Commit

Permalink
Album upload
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Sep 13, 2022
1 parent b076960 commit 863b02b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Sabre\DAV\ICollection;
use Sabre\DAV\ICopyTarget;
use Sabre\DAV\INode;
use OCP\Files\NotPermittedException;

class AlbumRoot implements ICollection, ICopyTarget {
private AlbumMapper $albumMapper;
Expand Down Expand Up @@ -87,12 +88,18 @@ public function setName($name) {
*/
public function createFile($name, $data = null) {
try {
// userConfigService->getUserConfig handle the path creation if missing
$photosLocation = $this->userConfigService->getUserConfig('photosLocation');

$photosFolder = $this->userFolder->get($photosLocation);
if (!($photosFolder instanceof Folder)) {
throw new Conflict('The destination exists and is not a folder');
}

$node = $photosFolder->newFile($name, $data);
return $this->addFile($node->getId(), $node->getOwner()->getUID());
} catch (\Exception $e) {
throw new \Exception('The file could not be created');
throw new Forbidden('Could not create file');
}
}

Expand Down Expand Up @@ -150,6 +157,7 @@ private function addFile(int $sourceId, string $ownerUID): bool {
$this->albumMapper->addFile($this->album->getAlbum()->getId(), $sourceId);
return true;
}
return false;
}

public function getAlbum(): AlbumWithFiles {
Expand Down

0 comments on commit 863b02b

Please sign in to comment.