1 | <?php |
||
7 | class UploadOptions |
||
8 | { |
||
9 | /** |
||
10 | * upload Create Dir Mode file Mask (default '0755') |
||
11 | * @var string |
||
12 | */ |
||
13 | public $uploadCreateDirModeMask = '0755'; |
||
14 | |||
15 | /** |
||
16 | * If set to true, a $model->uploadFileNameSuffixSeparator.$model->id suffx are added to upload file name. |
||
17 | * Ex.: |
||
18 | * original uploaded file name: pippo.jpg |
||
19 | * final name: 'pippo'.$model->uploadFileNameSuffixSeparator.$model->id.'jpg' |
||
20 | * @var bool |
||
21 | */ |
||
22 | public $appendModelIdSuffixInUploadedFileName = true; |
||
23 | |||
24 | /** |
||
25 | * Suffix separator to generate new file name |
||
26 | * @var string |
||
27 | */ |
||
28 | public $uploadFileNameSuffixSeparator = '_'; |
||
29 | |||
30 | /** |
||
31 | * Array of upload attributes |
||
32 | * Ex.: |
||
33 | * public $uploads = ['image', 'image_mobile']; |
||
34 | * @var array |
||
35 | */ |
||
36 | public $uploads = []; |
||
37 | |||
38 | /** |
||
39 | * Array of Mime type string. |
||
40 | * Ex. (default): |
||
41 | * public $uploadsMimeType = [ |
||
42 | * 'image/gif', |
||
43 | * 'image/jpeg', |
||
44 | * 'image/png', |
||
45 | * ]; |
||
46 | * A full listing of MIME types and their corresponding extensions may be found |
||
47 | * at the following location: http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types |
||
48 | * @var array |
||
49 | */ |
||
50 | public $uploadsMimeType = [ |
||
51 | 'image/gif', |
||
52 | 'image/jpeg', |
||
53 | 'image/png', |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * upload base path relative to $storageDiskName root folder |
||
58 | * @var string |
||
59 | */ |
||
60 | public $uploadBasePath; |
||
61 | |||
62 | /** |
||
63 | * The default storage disk name |
||
64 | * used for default upload base path |
||
65 | * default: public |
||
66 | * @var string |
||
67 | */ |
||
68 | public $storageDiskName = 'public'; |
||
69 | |||
70 | /** |
||
71 | * An associative array of 'attribute_name' => 'uploadBasePath' |
||
72 | * set an attribute name here to override its default upload base path |
||
73 | * The path is relative to $storageDiskName root folder. |
||
74 | * Ex.: |
||
75 | * public $uploadPaths = ['image' => 'product', 'image_thumb' => 'product/thumb']; |
||
76 | * @var array |
||
77 | */ |
||
78 | public $uploadPaths = []; |
||
79 | |||
80 | /** |
||
81 | * The laravel storage disk to store uploaded files |
||
82 | * @var \Illuminate\Filesystem\FilesystemAdapter |
||
83 | */ |
||
84 | public $storage; |
||
85 | |||
86 | |||
87 | /** |
||
88 | * @return UploadOptions |
||
89 | */ |
||
90 | public static function create(): UploadOptions |
||
94 | |||
95 | /** |
||
96 | * upload Create Dir Mode file Mask (Ex.: '0755') |
||
97 | * @param string $mask |
||
98 | * @return UploadOptions |
||
99 | */ |
||
100 | public function setCreateDirModeMask(string $mask): UploadOptions |
||
106 | |||
107 | /** |
||
108 | * $model->uploadFileNameSuffixSeparator.$model->id suffx are added to upload file name. |
||
109 | * Ex.: |
||
110 | * original uploaded file name: pippo.jpg |
||
111 | * final name: 'pippo'.$model->uploadFileNameSuffixSeparator.$model->id.'jpg' |
||
112 | */ |
||
113 | public function appendModelIdSuffixInFileName(): UploadOptions |
||
119 | |||
120 | /** |
||
121 | */ |
||
122 | public function dontAppendModelIdSuffixInFileName(): UploadOptions |
||
128 | |||
129 | /** |
||
130 | * Suffix separator to generate new file name |
||
131 | * @param string $suffix |
||
132 | * @return UploadOptions |
||
133 | */ |
||
134 | public function setFileNameSuffixSeparator(string $suffix): UploadOptions |
||
140 | |||
141 | /** |
||
142 | * Array of upload attributes |
||
143 | * Ex.: ['image', 'image_mobile']; |
||
144 | * @param array $attributes |
||
145 | * @return UploadOptions |
||
146 | */ |
||
147 | public function setUploadsAttributes(array $attributes): UploadOptions |
||
153 | |||
154 | /** |
||
155 | * Array of Mime type string. |
||
156 | * Ex.: |
||
157 | * [ |
||
158 | * 'image/gif', |
||
159 | * 'image/jpeg', |
||
160 | * 'image/png', |
||
161 | * ]; |
||
162 | * A full listing of MIME types and their corresponding extensions may be found |
||
163 | * at the following location: http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types |
||
164 | * @param array $mime |
||
165 | * @return UploadOptions |
||
166 | */ |
||
167 | public function setMimeType(array $mime): UploadOptions |
||
173 | |||
174 | /** |
||
175 | * upload base path. path relative to $storageDiskName root folder |
||
176 | * Ex.: public/upload/news |
||
177 | * @param string $path |
||
178 | * @return UploadOptions |
||
179 | */ |
||
180 | public function setUploadBasePath(string $path): UploadOptions |
||
186 | |||
187 | /** |
||
188 | * An associative array of 'attribute_name' => 'uploadBasePath' |
||
189 | * set an attribute name here to override its default upload base path |
||
190 | * The path is relative to $storageDiskName root folder. |
||
191 | * Ex.: |
||
192 | * public $uploadPaths = ['image' => 'product', 'image_thumb' => 'product/thumb']; |
||
193 | * @param array $attributesPaths |
||
194 | * @return UploadOptions |
||
195 | */ |
||
196 | public function setUploadPaths(array $attributesPaths): UploadOptions |
||
206 | |||
207 | /** |
||
208 | * Set a Storage Disk name |
||
209 | * @param string $diskName |
||
210 | * @return UploadOptions |
||
211 | */ |
||
212 | public function setStorageDisk(string $diskName) |
||
218 | |||
219 | /** |
||
220 | * Get a Storage Disk |
||
221 | * @return \Illuminate\Filesystem\FilesystemAdapter |
||
222 | */ |
||
223 | public function getStorage() : \Illuminate\Filesystem\FilesystemAdapter |
||
227 | |||
228 | /** |
||
229 | * Get the options for generating the upload. |
||
230 | */ |
||
231 | public function getUploadOptionsDefault(): UploadOptions |
||
247 | } |
||
248 |