PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.2
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.2
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Services / FileSystem / Drivers / BaseDriver.php

BaseDriver.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.5.2, at app/Services/FileSystem/Drivers/BaseDriver.php

67 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\FileSystem\Drivers;
4
5 use FluentCart\App\Modules\StorageDrivers\BaseStorageDriver;
6
7 abstract class BaseDriver
8 {
9 protected ?string $dirPath;
10 protected ?string $dirName;
11
12 protected ?BaseStorageDriver $storageDriver;
13
14 public function __construct(?string $dirPath = null, ?string $dirName = null)
15 {
16 $this->dirName = $dirName;
17 $this->dirPath = $dirPath;
18 }
19
20 public function getStorageDriver(): ?BaseStorageDriver
21 {
22 return $this->storageDriver;
23 }
24
25 public function saveSettings($params)
26 {
27 return $this->storageDriver->saveSettings($params);
28 }
29
30 protected abstract function getDefaultDirPath();
31
32 public abstract function listFiles(array $params = []);
33
34 public abstract function uploadFile($localFilePath, $uploadToFilePath, $file, $params = []);
35
36
37 public abstract function downloadFile(string $filePath);
38
39 public abstract function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null);
40
41 public abstract function getFilePath(string $filePath);
42
43 protected abstract function retrieveFileForDownload(string $downloadableFilePath);
44
45 public function setDownloadHeader($fileName, $file, $fileSize = null)
46 {
47 $extension = pathinfo($file, PATHINFO_EXTENSION);
48 // Append extension if $fileName doesn't already have one
49 if (pathinfo($fileName, PATHINFO_EXTENSION) === '') {
50 $fileName .= '.' . $extension;
51 }
52
53 header('Content-Description: File Transfer');
54 header('Content-Type: application/octet-stream', true, 200);
55 header('Content-Disposition: attachment; filename="' . $fileName . '"');
56 if (!empty($fileSize)) {
57 header('Content-Length: ' . $fileSize);
58 //header('Content-Length: ' . filesize($file));
59 }
60
61 header('Expires: 0');
62 header('Cache-Control: must-revalidate');
63 header('Pragma: public');
64 }
65
66
67 }