fixing bugs

This commit is contained in:
omair saleh
2021-04-21 16:53:11 +08:00
parent 009dcda138
commit 9d2fcda5e6
3 changed files with 6 additions and 8 deletions
@@ -20,13 +20,10 @@ class ConvertsBase64ToFile
* ConvertsBase64ToFile constructor.
* @param null|string $path
*/
public function __construct(?string $path = '')
public function __construct(?string $path = 'documents')
{
$this->path = $path ? $path.'/': '';
$this->path = $path;
$this->filesInfo = [];
File::isDirectory(storage_path($this->path)) or
File::makeDirectory(storage_path($this->path), 0700, true, true);
}
@@ -37,6 +34,7 @@ class ConvertsBase64ToFile
*/
public function convert($files = []){
foreach ($files as $file) {
$object = new FileObject($file);
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
@@ -101,7 +99,7 @@ class ConvertsBase64ToFile
*/
private function generateFile(FileObject $file, string $suffix = '') {
$filePath = $this->path.$file->getFileName().$suffix.'.'.$file->getExtension();
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
Storage::disk('documents')->put($filePath, $file->getDecodedData());