PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 trunk 1.2.0 All 47 releases
fluent-cart / app / Services / FileSystem / Drivers / BaseDriver.php

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

72 lines 2.0 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 public function buckets()
31 {
32 return [];
33 }
34
35 protected abstract function getDefaultDirPath();
36
37 public abstract function listFiles(array $params = []);
38
39 public abstract function uploadFile($localFilePath, $uploadToFilePath, $file, $params = []);
40
41
42 public abstract function downloadFile(string $filePath);
43
44 public abstract function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null);
45
46 public abstract function getFilePath(string $filePath);
47
48 protected abstract function retrieveFileForDownload(string $downloadableFilePath);
49
50 public function setDownloadHeader($fileName, $file, $fileSize = null)
51 {
52 $extension = pathinfo($file, PATHINFO_EXTENSION);
53 // Append extension if $fileName doesn't already have one
54 if (pathinfo($fileName, PATHINFO_EXTENSION) === '') {
55 $fileName .= '.' . $extension;
56 }
57
58 header('Content-Description: File Transfer');
59 header('Content-Type: application/octet-stream', true, 200);
60 header('Content-Disposition: attachment; filename="' . $fileName . '"');
61 if (!empty($fileSize)) {
62 header('Content-Length: ' . $fileSize);
63 //header('Content-Length: ' . filesize($file));
64 }
65
66 header('Expires: 0');
67 header('Cache-Control: must-revalidate');
68 header('Pragma: public');
69 }
70
71
72 }