Skip to content

Commit

Permalink
Added support upload base64
Browse files Browse the repository at this point in the history
  • Loading branch information
nilov committed Feb 3, 2017
1 parent bac722f commit e2104dd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Storage/FilesystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ public function upload(FileInterface $file, $directory, $name = null)

/**
* @param string $link
* @param string $name
* @param string $directory
* @return FileInterface|false
*/
public function uploadTmpFileByLink($link)
{
$fileContents = $this->getContentsByLink($link);
if ($this->isUrl($link)) {
$fileContents = $this->getContentsByLink($link);

} else {
$fileContents = $this->getContentsFromBase64($link);
}

if (!$fileContents) {
return false;
Expand Down Expand Up @@ -93,6 +96,15 @@ protected function getContentsByLink($link)
return $fileContents;
}

/**
* @param string $base64
* @return string
*/
private function getContentsFromBase64($base64)
{
return base64_decode($base64);
}

/**
* @param $url
* @return bool
Expand Down

0 comments on commit e2104dd

Please sign in to comment.