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. * ConvertsBase64ToFile constructor.
* @param null|string $path * @param null|string $path
*/ */
public function __construct(?string $path = '') public function __construct(?string $path = 'documents')
{ {
$this->path = $path ? $path.'/': ''; $this->path = $path;
$this->filesInfo = []; $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 = []){ public function convert($files = []){
foreach ($files as $file) { foreach ($files as $file) {
$object = new FileObject($file); $object = new FileObject($file);
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object); $object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
@@ -101,7 +99,7 @@ class ConvertsBase64ToFile
*/ */
private function generateFile(FileObject $file, string $suffix = '') { 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()); Storage::disk('documents')->put($filePath, $file->getDecodedData());
+1 -1
View File
@@ -7,7 +7,7 @@ require_once "vendor/autoload.php";
// If you have modified your font directory set this // If you have modified your font directory set this
// variable appropriately. // variable appropriately.
//$fontDir = "lib/fonts"; //$fontDir = "lib/fonts";
$fontDir = 'storage/fonts';
// *** DO NOT MODIFY BELOW THIS POINT *** // *** DO NOT MODIFY BELOW THIS POINT ***
@@ -58,7 +58,7 @@
} }
}, },
errorHandler(error, statusCode){ errorHandler(error, statusCode){
this.src = statusCode === 404 ? 'images/3231370.jpg' : 'images/2942005.jpg' this.src = statusCode === 404 ? '/images/3231370.jpg' : '/images/2942005.jpg'
this.isLoading = false; this.isLoading = false;
} }
}, },