Skip to content

Commit

Permalink
Support downloading files
Browse files Browse the repository at this point in the history
  • Loading branch information
joostfaassen committed May 8, 2015
1 parent 4eaf6f9 commit e3abd38
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Service/PdoService.php
Expand Up @@ -146,6 +146,7 @@ private function row2file($row)
$file->setDeletedAt($row['deleted_at']);
$file->setSizeOriginal($row['size_original']);
$file->setSizeStorage($row['size_storage']);
$file->setDataHash($row['data_hash']);


return $file;
Expand Down Expand Up @@ -180,6 +181,15 @@ public function upload(Space $space, $filekey, $filename)
$this->storage->setData($hash, $data);
$this->persistFile($space, $file);
}

public function download(Space $space, $filekey, $filename)
{
$file = $this->getFile($space, $filekey);
print_r($file);
$hash = $file->getDataHash();
$data = $this->storage->getData($hash);
file_put_contents($filename, $data);
}

private function persistFile(Space $space, File $file)
{
Expand Down

0 comments on commit e3abd38

Please sign in to comment.