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