Passed
Push — master ( cb2b38...37146c )
by Roeland
12:06 queued 11s
created
lib/private/Preview/Krita.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@
 block discarded – undo
27 27
 use OCP\IImage;
28 28
 
29 29
 class Krita extends Bundled {
30
-	/**
31
-	 * {@inheritDoc}
32
-	 */
33
-	public function getMimeType(): string {
34
-		return '/application\/x-krita/';
35
-	}
30
+    /**
31
+     * {@inheritDoc}
32
+     */
33
+    public function getMimeType(): string {
34
+        return '/application\/x-krita/';
35
+    }
36 36
 
37 37
 
38
-	/**
39
-	 * @inheritDoc
40
-	 */
41
-	public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
42
-		$image = $this->extractThumbnail($file, 'mergedimage.png');
43
-		if ($image->valid()) {
44
-			return $image;
45
-		}
46
-		$image = $this->extractThumbnail($file, 'preview.png');
47
-		if ($image->valid()) {
48
-			return $image;
49
-		}
50
-		return null;
51
-	}
38
+    /**
39
+     * @inheritDoc
40
+     */
41
+    public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
42
+        $image = $this->extractThumbnail($file, 'mergedimage.png');
43
+        if ($image->valid()) {
44
+            return $image;
45
+        }
46
+        $image = $this->extractThumbnail($file, 'preview.png');
47
+        if ($image->valid()) {
48
+            return $image;
49
+        }
50
+        return null;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
lib/private/Preview/Bundled.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@
 block discarded – undo
32 32
  */
33 33
 abstract class Bundled extends ProviderV2 {
34 34
 
35
-	protected function extractThumbnail(File $file, $path): ?IImage {
36
-		$sourceTmp = \OC::$server->getTempManager()->getTemporaryFile();
37
-		$targetTmp = \OC::$server->getTempManager()->getTemporaryFile();
38
-
39
-		try {
40
-			$content = $file->fopen('r');
41
-			file_put_contents($sourceTmp, $content);
42
-
43
-			$zip = new ZIP($sourceTmp);
44
-			$zip->extractFile($path, $targetTmp);
45
-
46
-			$image = new \OC_Image();
47
-			$image->loadFromFile($targetTmp);
48
-			$image->fixOrientation();
49
-
50
-			return $image;
51
-		} catch (\Exception $e) {
52
-			return null;
53
-		}
54
-	}
35
+    protected function extractThumbnail(File $file, $path): ?IImage {
36
+        $sourceTmp = \OC::$server->getTempManager()->getTemporaryFile();
37
+        $targetTmp = \OC::$server->getTempManager()->getTemporaryFile();
38
+
39
+        try {
40
+            $content = $file->fopen('r');
41
+            file_put_contents($sourceTmp, $content);
42
+
43
+            $zip = new ZIP($sourceTmp);
44
+            $zip->extractFile($path, $targetTmp);
45
+
46
+            $image = new \OC_Image();
47
+            $image->loadFromFile($targetTmp);
48
+            $image->fixOrientation();
49
+
50
+            return $image;
51
+        } catch (\Exception $e) {
52
+            return null;
53
+        }
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
lib/private/Preview/OpenDocument.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
29 29
 use OCP\IImage;
30 30
 
31 31
 class OpenDocument extends Bundled {
32
-	/**
33
-	 * {@inheritDoc}
34
-	 */
35
-	public function getMimeType(): string {
36
-		return '/application\/vnd.oasis.opendocument.*/';
37
-	}
32
+    /**
33
+     * {@inheritDoc}
34
+     */
35
+    public function getMimeType(): string {
36
+        return '/application\/vnd.oasis.opendocument.*/';
37
+    }
38 38
 
39 39
 
40
-	/**
41
-	 * @inheritDoc
42
-	 */
43
-	public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
44
-		$image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png');
45
-		if ($image->valid()) {
46
-			return $image;
47
-		}
48
-		return null;
49
-	}
40
+    /**
41
+     * @inheritDoc
42
+     */
43
+    public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
44
+        $image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png');
45
+        if ($image->valid()) {
46
+            return $image;
47
+        }
48
+        return null;
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/PreviewManager.php 1 patch
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -42,372 +42,372 @@
 block discarded – undo
42 42
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
43 43
 
44 44
 class PreviewManager implements IPreview {
45
-	/** @var IConfig */
46
-	protected $config;
45
+    /** @var IConfig */
46
+    protected $config;
47 47
 
48
-	/** @var IRootFolder */
49
-	protected $rootFolder;
48
+    /** @var IRootFolder */
49
+    protected $rootFolder;
50 50
 
51
-	/** @var IAppData */
52
-	protected $appData;
51
+    /** @var IAppData */
52
+    protected $appData;
53 53
 
54
-	/** @var EventDispatcherInterface */
55
-	protected $eventDispatcher;
54
+    /** @var EventDispatcherInterface */
55
+    protected $eventDispatcher;
56 56
 
57
-	/** @var Generator */
58
-	private $generator;
57
+    /** @var Generator */
58
+    private $generator;
59 59
 	
60
-	/** @var GeneratorHelper */
61
-	private $helper;
62
-
63
-	/** @var bool */
64
-	protected $providerListDirty = false;
65
-
66
-	/** @var bool */
67
-	protected $registeredCoreProviders = false;
68
-
69
-	/** @var array */
70
-	protected $providers = [];
71
-
72
-	/** @var array mime type => support status */
73
-	protected $mimeTypeSupportMap = [];
74
-
75
-	/** @var array */
76
-	protected $defaultProviders;
77
-
78
-	/** @var string */
79
-	protected $userId;
80
-
81
-	/**
82
-	 * PreviewManager constructor.
83
-	 *
84
-	 * @param IConfig $config
85
-	 * @param IRootFolder $rootFolder
86
-	 * @param IAppData $appData
87
-	 * @param EventDispatcherInterface $eventDispatcher
88
-	 * @param string $userId
89
-	 */
90
-	public function __construct(IConfig $config,
91
-								IRootFolder $rootFolder,
92
-								IAppData $appData,
93
-								EventDispatcherInterface $eventDispatcher,
94
-								GeneratorHelper $helper,
95
-								$userId) {
96
-		$this->config = $config;
97
-		$this->rootFolder = $rootFolder;
98
-		$this->appData = $appData;
99
-		$this->eventDispatcher = $eventDispatcher;
100
-		$this->helper = $helper;
101
-		$this->userId = $userId;
102
-	}
103
-
104
-	/**
105
-	 * In order to improve lazy loading a closure can be registered which will be
106
-	 * called in case preview providers are actually requested
107
-	 *
108
-	 * $callable has to return an instance of \OCP\Preview\IProvider or \OCP\Preview\IProviderV2
109
-	 *
110
-	 * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
111
-	 * @param \Closure $callable
112
-	 * @return void
113
-	 */
114
-	public function registerProvider($mimeTypeRegex, \Closure $callable) {
115
-		if (!$this->config->getSystemValue('enable_previews', true)) {
116
-			return;
117
-		}
118
-
119
-		if (!isset($this->providers[$mimeTypeRegex])) {
120
-			$this->providers[$mimeTypeRegex] = [];
121
-		}
122
-		$this->providers[$mimeTypeRegex][] = $callable;
123
-		$this->providerListDirty = true;
124
-	}
125
-
126
-	/**
127
-	 * Get all providers
128
-	 * @return array
129
-	 */
130
-	public function getProviders() {
131
-		if (!$this->config->getSystemValue('enable_previews', true)) {
132
-			return [];
133
-		}
134
-
135
-		$this->registerCoreProviders();
136
-		if ($this->providerListDirty) {
137
-			$keys = array_map('strlen', array_keys($this->providers));
138
-			array_multisort($keys, SORT_DESC, $this->providers);
139
-			$this->providerListDirty = false;
140
-		}
141
-
142
-		return $this->providers;
143
-	}
144
-
145
-	/**
146
-	 * Does the manager have any providers
147
-	 * @return bool
148
-	 */
149
-	public function hasProviders() {
150
-		$this->registerCoreProviders();
151
-		return !empty($this->providers);
152
-	}
153
-
154
-	/**
155
-	 * Returns a preview of a file
156
-	 *
157
-	 * The cache is searched first and if nothing usable was found then a preview is
158
-	 * generated by one of the providers
159
-	 *
160
-	 * @param File $file
161
-	 * @param int $width
162
-	 * @param int $height
163
-	 * @param bool $crop
164
-	 * @param string $mode
165
-	 * @param string $mimeType
166
-	 * @return ISimpleFile
167
-	 * @throws NotFoundException
168
-	 * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
169
-	 * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
170
-	 */
171
-	public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) {
172
-		if ($this->generator === null) {
173
-			$this->generator = new Generator(
174
-				$this->config,
175
-				$this,
176
-				$this->appData,
177
-				new GeneratorHelper(
178
-					$this->rootFolder,
179
-					$this->config
180
-				),
181
-				$this->eventDispatcher
182
-			);
183
-		}
184
-
185
-		return $this->generator->getPreview($file, $width, $height, $crop, $mode, $mimeType);
186
-	}
187
-
188
-	/**
189
-	 * returns true if the passed mime type is supported
190
-	 *
191
-	 * @param string $mimeType
192
-	 * @return boolean
193
-	 */
194
-	public function isMimeSupported($mimeType = '*') {
195
-		if (!$this->config->getSystemValue('enable_previews', true)) {
196
-			return false;
197
-		}
198
-
199
-		if (isset($this->mimeTypeSupportMap[$mimeType])) {
200
-			return $this->mimeTypeSupportMap[$mimeType];
201
-		}
202
-
203
-		$this->registerCoreProviders();
204
-		$providerMimeTypes = array_keys($this->providers);
205
-		foreach ($providerMimeTypes as $supportedMimeType) {
206
-			if (preg_match($supportedMimeType, $mimeType)) {
207
-				$this->mimeTypeSupportMap[$mimeType] = true;
208
-				return true;
209
-			}
210
-		}
211
-		$this->mimeTypeSupportMap[$mimeType] = false;
212
-		return false;
213
-	}
214
-
215
-	/**
216
-	 * Check if a preview can be generated for a file
217
-	 *
218
-	 * @param \OCP\Files\FileInfo $file
219
-	 * @return bool
220
-	 */
221
-	public function isAvailable(\OCP\Files\FileInfo $file) {
222
-		if (!$this->config->getSystemValue('enable_previews', true)) {
223
-			return false;
224
-		}
225
-
226
-		$this->registerCoreProviders();
227
-		if (!$this->isMimeSupported($file->getMimetype())) {
228
-			return false;
229
-		}
230
-
231
-		$mount = $file->getMountPoint();
232
-		if ($mount and !$mount->getOption('previews', true)){
233
-			return false;
234
-		}
235
-
236
-		foreach ($this->providers as $supportedMimeType => $providers) {
237
-			if (preg_match($supportedMimeType, $file->getMimetype())) {
238
-				foreach ($providers as $providerClosure) {
239
-					$provider = $this->helper->getProvider($providerClosure);
240
-					if (!($provider instanceof IProviderV2)) {
241
-						continue;
242
-					}
243
-
244
-					/** @var $provider IProvider */
245
-					if ($provider->isAvailable($file)) {
246
-						return true;
247
-					}
248
-				}
249
-			}
250
-		}
251
-		return false;
252
-	}
253
-
254
-	/**
255
-	 * List of enabled default providers
256
-	 *
257
-	 * The following providers are enabled by default:
258
-	 *  - OC\Preview\PNG
259
-	 *  - OC\Preview\JPEG
260
-	 *  - OC\Preview\GIF
261
-	 *  - OC\Preview\BMP
262
-	 *  - OC\Preview\HEIC
263
-	 *  - OC\Preview\XBitmap
264
-	 *  - OC\Preview\MarkDown
265
-	 *  - OC\Preview\MP3
266
-	 *  - OC\Preview\TXT
267
-	 *
268
-	 * The following providers are disabled by default due to performance or privacy concerns:
269
-	 *  - OC\Preview\Font
270
-	 *  - OC\Preview\Illustrator
271
-	 *  - OC\Preview\Movie
272
-	 *  - OC\Preview\MSOfficeDoc
273
-	 *  - OC\Preview\MSOffice2003
274
-	 *  - OC\Preview\MSOffice2007
275
-	 *  - OC\Preview\OpenDocument
276
-	 *  - OC\Preview\PDF
277
-	 *  - OC\Preview\Photoshop
278
-	 *  - OC\Preview\Postscript
279
-	 *  - OC\Preview\StarOffice
280
-	 *  - OC\Preview\SVG
281
-	 *  - OC\Preview\TIFF
282
-	 *
283
-	 * @return array
284
-	 */
285
-	protected function getEnabledDefaultProvider() {
286
-		if ($this->defaultProviders !== null) {
287
-			return $this->defaultProviders;
288
-		}
289
-
290
-		$imageProviders = [
291
-			Preview\PNG::class,
292
-			Preview\JPEG::class,
293
-			Preview\GIF::class,
294
-			Preview\BMP::class,
295
-			Preview\HEIC::class,
296
-			Preview\XBitmap::class,
297
-			Preview\Krita::class,
298
-		];
299
-
300
-		$this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', array_merge([
301
-			Preview\MarkDown::class,
302
-			Preview\MP3::class,
303
-			Preview\TXT::class,
304
-			Preview\OpenDocument::class,
305
-		], $imageProviders));
306
-
307
-		if (in_array(Preview\Image::class, $this->defaultProviders)) {
308
-			$this->defaultProviders = array_merge($this->defaultProviders, $imageProviders);
309
-		}
310
-		$this->defaultProviders = array_unique($this->defaultProviders);
311
-		return $this->defaultProviders;
312
-	}
313
-
314
-	/**
315
-	 * Register the default providers (if enabled)
316
-	 *
317
-	 * @param string $class
318
-	 * @param string $mimeType
319
-	 */
320
-	protected function registerCoreProvider($class, $mimeType, $options = []) {
321
-		if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
322
-			$this->registerProvider($mimeType, function () use ($class, $options) {
323
-				return new $class($options);
324
-			});
325
-		}
326
-	}
327
-
328
-	/**
329
-	 * Register the default providers (if enabled)
330
-	 */
331
-	protected function registerCoreProviders() {
332
-		if ($this->registeredCoreProviders) {
333
-			return;
334
-		}
335
-		$this->registeredCoreProviders = true;
336
-
337
-		$this->registerCoreProvider(Preview\TXT::class, '/text\/plain/');
338
-		$this->registerCoreProvider(Preview\MarkDown::class, '/text\/(x-)?markdown/');
339
-		$this->registerCoreProvider(Preview\PNG::class, '/image\/png/');
340
-		$this->registerCoreProvider(Preview\JPEG::class, '/image\/jpeg/');
341
-		$this->registerCoreProvider(Preview\GIF::class, '/image\/gif/');
342
-		$this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/');
343
-		$this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/');
344
-		$this->registerCoreProvider(Preview\Krita::class, '/application\/x-krita/');
345
-		$this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/');
346
-		$this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
347
-
348
-		// SVG, Office and Bitmap require imagick
349
-		if (extension_loaded('imagick')) {
350
-			$checkImagick = new \Imagick();
351
-
352
-			$imagickProviders = [
353
-				'SVG'	=> ['mimetype' => '/image\/svg\+xml/', 'class' => Preview\SVG::class],
354
-				'TIFF'	=> ['mimetype' => '/image\/tiff/', 'class' => Preview\TIFF::class],
355
-				'PDF'	=> ['mimetype' => '/application\/pdf/', 'class' => Preview\PDF::class],
356
-				'AI'	=> ['mimetype' => '/application\/illustrator/', 'class' => Preview\Illustrator::class],
357
-				'PSD'	=> ['mimetype' => '/application\/x-photoshop/', 'class' => Preview\Photoshop::class],
358
-				'EPS'	=> ['mimetype' => '/application\/postscript/', 'class' => Preview\Postscript::class],
359
-				'TTF'	=> ['mimetype' => '/application\/(?:font-sfnt|x-font$)/', 'class' => Preview\Font::class],
360
-				'HEIC'  => ['mimetype' => '/image\/hei(f|c)/', 'class' => Preview\HEIC::class],
361
-			];
362
-
363
-			foreach ($imagickProviders as $queryFormat => $provider) {
364
-				$class = $provider['class'];
365
-				if (!in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
366
-					continue;
367
-				}
368
-
369
-				if (count($checkImagick->queryFormats($queryFormat)) === 1) {
370
-					$this->registerCoreProvider($class, $provider['mimetype']);
371
-				}
372
-			}
373
-
374
-			if (count($checkImagick->queryFormats('PDF')) === 1) {
375
-				if (\OC_Helper::is_function_enabled('shell_exec')) {
376
-					$officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null));
377
-
378
-					if (!$officeFound) {
379
-						//let's see if there is libreoffice or openoffice on this machine
380
-						$whichLibreOffice = shell_exec('command -v libreoffice');
381
-						$officeFound = !empty($whichLibreOffice);
382
-						if (!$officeFound) {
383
-							$whichOpenOffice = shell_exec('command -v openoffice');
384
-							$officeFound = !empty($whichOpenOffice);
385
-						}
386
-					}
387
-
388
-					if ($officeFound) {
389
-						$this->registerCoreProvider(Preview\MSOfficeDoc::class, '/application\/msword/');
390
-						$this->registerCoreProvider(Preview\MSOffice2003::class, '/application\/vnd.ms-.*/');
391
-						$this->registerCoreProvider(Preview\MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/');
392
-						$this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
393
-						$this->registerCoreProvider(Preview\StarOffice::class, '/application\/vnd.sun.xml.*/');
394
-					}
395
-				}
396
-			}
397
-		}
398
-
399
-		// Video requires avconv or ffmpeg
400
-		if (in_array(Preview\Movie::class, $this->getEnabledDefaultProvider())) {
401
-			$avconvBinary = \OC_Helper::findBinaryPath('avconv');
402
-			$ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg');
403
-
404
-			if ($avconvBinary || $ffmpegBinary) {
405
-				// FIXME // a bit hacky but didn't want to use subclasses
406
-				\OC\Preview\Movie::$avconvBinary = $avconvBinary;
407
-				\OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
408
-
409
-				$this->registerCoreProvider(Preview\Movie::class, '/video\/.*/');
410
-			}
411
-		}
412
-	}
60
+    /** @var GeneratorHelper */
61
+    private $helper;
62
+
63
+    /** @var bool */
64
+    protected $providerListDirty = false;
65
+
66
+    /** @var bool */
67
+    protected $registeredCoreProviders = false;
68
+
69
+    /** @var array */
70
+    protected $providers = [];
71
+
72
+    /** @var array mime type => support status */
73
+    protected $mimeTypeSupportMap = [];
74
+
75
+    /** @var array */
76
+    protected $defaultProviders;
77
+
78
+    /** @var string */
79
+    protected $userId;
80
+
81
+    /**
82
+     * PreviewManager constructor.
83
+     *
84
+     * @param IConfig $config
85
+     * @param IRootFolder $rootFolder
86
+     * @param IAppData $appData
87
+     * @param EventDispatcherInterface $eventDispatcher
88
+     * @param string $userId
89
+     */
90
+    public function __construct(IConfig $config,
91
+                                IRootFolder $rootFolder,
92
+                                IAppData $appData,
93
+                                EventDispatcherInterface $eventDispatcher,
94
+                                GeneratorHelper $helper,
95
+                                $userId) {
96
+        $this->config = $config;
97
+        $this->rootFolder = $rootFolder;
98
+        $this->appData = $appData;
99
+        $this->eventDispatcher = $eventDispatcher;
100
+        $this->helper = $helper;
101
+        $this->userId = $userId;
102
+    }
103
+
104
+    /**
105
+     * In order to improve lazy loading a closure can be registered which will be
106
+     * called in case preview providers are actually requested
107
+     *
108
+     * $callable has to return an instance of \OCP\Preview\IProvider or \OCP\Preview\IProviderV2
109
+     *
110
+     * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
111
+     * @param \Closure $callable
112
+     * @return void
113
+     */
114
+    public function registerProvider($mimeTypeRegex, \Closure $callable) {
115
+        if (!$this->config->getSystemValue('enable_previews', true)) {
116
+            return;
117
+        }
118
+
119
+        if (!isset($this->providers[$mimeTypeRegex])) {
120
+            $this->providers[$mimeTypeRegex] = [];
121
+        }
122
+        $this->providers[$mimeTypeRegex][] = $callable;
123
+        $this->providerListDirty = true;
124
+    }
125
+
126
+    /**
127
+     * Get all providers
128
+     * @return array
129
+     */
130
+    public function getProviders() {
131
+        if (!$this->config->getSystemValue('enable_previews', true)) {
132
+            return [];
133
+        }
134
+
135
+        $this->registerCoreProviders();
136
+        if ($this->providerListDirty) {
137
+            $keys = array_map('strlen', array_keys($this->providers));
138
+            array_multisort($keys, SORT_DESC, $this->providers);
139
+            $this->providerListDirty = false;
140
+        }
141
+
142
+        return $this->providers;
143
+    }
144
+
145
+    /**
146
+     * Does the manager have any providers
147
+     * @return bool
148
+     */
149
+    public function hasProviders() {
150
+        $this->registerCoreProviders();
151
+        return !empty($this->providers);
152
+    }
153
+
154
+    /**
155
+     * Returns a preview of a file
156
+     *
157
+     * The cache is searched first and if nothing usable was found then a preview is
158
+     * generated by one of the providers
159
+     *
160
+     * @param File $file
161
+     * @param int $width
162
+     * @param int $height
163
+     * @param bool $crop
164
+     * @param string $mode
165
+     * @param string $mimeType
166
+     * @return ISimpleFile
167
+     * @throws NotFoundException
168
+     * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
169
+     * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
170
+     */
171
+    public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) {
172
+        if ($this->generator === null) {
173
+            $this->generator = new Generator(
174
+                $this->config,
175
+                $this,
176
+                $this->appData,
177
+                new GeneratorHelper(
178
+                    $this->rootFolder,
179
+                    $this->config
180
+                ),
181
+                $this->eventDispatcher
182
+            );
183
+        }
184
+
185
+        return $this->generator->getPreview($file, $width, $height, $crop, $mode, $mimeType);
186
+    }
187
+
188
+    /**
189
+     * returns true if the passed mime type is supported
190
+     *
191
+     * @param string $mimeType
192
+     * @return boolean
193
+     */
194
+    public function isMimeSupported($mimeType = '*') {
195
+        if (!$this->config->getSystemValue('enable_previews', true)) {
196
+            return false;
197
+        }
198
+
199
+        if (isset($this->mimeTypeSupportMap[$mimeType])) {
200
+            return $this->mimeTypeSupportMap[$mimeType];
201
+        }
202
+
203
+        $this->registerCoreProviders();
204
+        $providerMimeTypes = array_keys($this->providers);
205
+        foreach ($providerMimeTypes as $supportedMimeType) {
206
+            if (preg_match($supportedMimeType, $mimeType)) {
207
+                $this->mimeTypeSupportMap[$mimeType] = true;
208
+                return true;
209
+            }
210
+        }
211
+        $this->mimeTypeSupportMap[$mimeType] = false;
212
+        return false;
213
+    }
214
+
215
+    /**
216
+     * Check if a preview can be generated for a file
217
+     *
218
+     * @param \OCP\Files\FileInfo $file
219
+     * @return bool
220
+     */
221
+    public function isAvailable(\OCP\Files\FileInfo $file) {
222
+        if (!$this->config->getSystemValue('enable_previews', true)) {
223
+            return false;
224
+        }
225
+
226
+        $this->registerCoreProviders();
227
+        if (!$this->isMimeSupported($file->getMimetype())) {
228
+            return false;
229
+        }
230
+
231
+        $mount = $file->getMountPoint();
232
+        if ($mount and !$mount->getOption('previews', true)){
233
+            return false;
234
+        }
235
+
236
+        foreach ($this->providers as $supportedMimeType => $providers) {
237
+            if (preg_match($supportedMimeType, $file->getMimetype())) {
238
+                foreach ($providers as $providerClosure) {
239
+                    $provider = $this->helper->getProvider($providerClosure);
240
+                    if (!($provider instanceof IProviderV2)) {
241
+                        continue;
242
+                    }
243
+
244
+                    /** @var $provider IProvider */
245
+                    if ($provider->isAvailable($file)) {
246
+                        return true;
247
+                    }
248
+                }
249
+            }
250
+        }
251
+        return false;
252
+    }
253
+
254
+    /**
255
+     * List of enabled default providers
256
+     *
257
+     * The following providers are enabled by default:
258
+     *  - OC\Preview\PNG
259
+     *  - OC\Preview\JPEG
260
+     *  - OC\Preview\GIF
261
+     *  - OC\Preview\BMP
262
+     *  - OC\Preview\HEIC
263
+     *  - OC\Preview\XBitmap
264
+     *  - OC\Preview\MarkDown
265
+     *  - OC\Preview\MP3
266
+     *  - OC\Preview\TXT
267
+     *
268
+     * The following providers are disabled by default due to performance or privacy concerns:
269
+     *  - OC\Preview\Font
270
+     *  - OC\Preview\Illustrator
271
+     *  - OC\Preview\Movie
272
+     *  - OC\Preview\MSOfficeDoc
273
+     *  - OC\Preview\MSOffice2003
274
+     *  - OC\Preview\MSOffice2007
275
+     *  - OC\Preview\OpenDocument
276
+     *  - OC\Preview\PDF
277
+     *  - OC\Preview\Photoshop
278
+     *  - OC\Preview\Postscript
279
+     *  - OC\Preview\StarOffice
280
+     *  - OC\Preview\SVG
281
+     *  - OC\Preview\TIFF
282
+     *
283
+     * @return array
284
+     */
285
+    protected function getEnabledDefaultProvider() {
286
+        if ($this->defaultProviders !== null) {
287
+            return $this->defaultProviders;
288
+        }
289
+
290
+        $imageProviders = [
291
+            Preview\PNG::class,
292
+            Preview\JPEG::class,
293
+            Preview\GIF::class,
294
+            Preview\BMP::class,
295
+            Preview\HEIC::class,
296
+            Preview\XBitmap::class,
297
+            Preview\Krita::class,
298
+        ];
299
+
300
+        $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', array_merge([
301
+            Preview\MarkDown::class,
302
+            Preview\MP3::class,
303
+            Preview\TXT::class,
304
+            Preview\OpenDocument::class,
305
+        ], $imageProviders));
306
+
307
+        if (in_array(Preview\Image::class, $this->defaultProviders)) {
308
+            $this->defaultProviders = array_merge($this->defaultProviders, $imageProviders);
309
+        }
310
+        $this->defaultProviders = array_unique($this->defaultProviders);
311
+        return $this->defaultProviders;
312
+    }
313
+
314
+    /**
315
+     * Register the default providers (if enabled)
316
+     *
317
+     * @param string $class
318
+     * @param string $mimeType
319
+     */
320
+    protected function registerCoreProvider($class, $mimeType, $options = []) {
321
+        if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
322
+            $this->registerProvider($mimeType, function () use ($class, $options) {
323
+                return new $class($options);
324
+            });
325
+        }
326
+    }
327
+
328
+    /**
329
+     * Register the default providers (if enabled)
330
+     */
331
+    protected function registerCoreProviders() {
332
+        if ($this->registeredCoreProviders) {
333
+            return;
334
+        }
335
+        $this->registeredCoreProviders = true;
336
+
337
+        $this->registerCoreProvider(Preview\TXT::class, '/text\/plain/');
338
+        $this->registerCoreProvider(Preview\MarkDown::class, '/text\/(x-)?markdown/');
339
+        $this->registerCoreProvider(Preview\PNG::class, '/image\/png/');
340
+        $this->registerCoreProvider(Preview\JPEG::class, '/image\/jpeg/');
341
+        $this->registerCoreProvider(Preview\GIF::class, '/image\/gif/');
342
+        $this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/');
343
+        $this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/');
344
+        $this->registerCoreProvider(Preview\Krita::class, '/application\/x-krita/');
345
+        $this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/');
346
+        $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
347
+
348
+        // SVG, Office and Bitmap require imagick
349
+        if (extension_loaded('imagick')) {
350
+            $checkImagick = new \Imagick();
351
+
352
+            $imagickProviders = [
353
+                'SVG'	=> ['mimetype' => '/image\/svg\+xml/', 'class' => Preview\SVG::class],
354
+                'TIFF'	=> ['mimetype' => '/image\/tiff/', 'class' => Preview\TIFF::class],
355
+                'PDF'	=> ['mimetype' => '/application\/pdf/', 'class' => Preview\PDF::class],
356
+                'AI'	=> ['mimetype' => '/application\/illustrator/', 'class' => Preview\Illustrator::class],
357
+                'PSD'	=> ['mimetype' => '/application\/x-photoshop/', 'class' => Preview\Photoshop::class],
358
+                'EPS'	=> ['mimetype' => '/application\/postscript/', 'class' => Preview\Postscript::class],
359
+                'TTF'	=> ['mimetype' => '/application\/(?:font-sfnt|x-font$)/', 'class' => Preview\Font::class],
360
+                'HEIC'  => ['mimetype' => '/image\/hei(f|c)/', 'class' => Preview\HEIC::class],
361
+            ];
362
+
363
+            foreach ($imagickProviders as $queryFormat => $provider) {
364
+                $class = $provider['class'];
365
+                if (!in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
366
+                    continue;
367
+                }
368
+
369
+                if (count($checkImagick->queryFormats($queryFormat)) === 1) {
370
+                    $this->registerCoreProvider($class, $provider['mimetype']);
371
+                }
372
+            }
373
+
374
+            if (count($checkImagick->queryFormats('PDF')) === 1) {
375
+                if (\OC_Helper::is_function_enabled('shell_exec')) {
376
+                    $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null));
377
+
378
+                    if (!$officeFound) {
379
+                        //let's see if there is libreoffice or openoffice on this machine
380
+                        $whichLibreOffice = shell_exec('command -v libreoffice');
381
+                        $officeFound = !empty($whichLibreOffice);
382
+                        if (!$officeFound) {
383
+                            $whichOpenOffice = shell_exec('command -v openoffice');
384
+                            $officeFound = !empty($whichOpenOffice);
385
+                        }
386
+                    }
387
+
388
+                    if ($officeFound) {
389
+                        $this->registerCoreProvider(Preview\MSOfficeDoc::class, '/application\/msword/');
390
+                        $this->registerCoreProvider(Preview\MSOffice2003::class, '/application\/vnd.ms-.*/');
391
+                        $this->registerCoreProvider(Preview\MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/');
392
+                        $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
393
+                        $this->registerCoreProvider(Preview\StarOffice::class, '/application\/vnd.sun.xml.*/');
394
+                    }
395
+                }
396
+            }
397
+        }
398
+
399
+        // Video requires avconv or ffmpeg
400
+        if (in_array(Preview\Movie::class, $this->getEnabledDefaultProvider())) {
401
+            $avconvBinary = \OC_Helper::findBinaryPath('avconv');
402
+            $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg');
403
+
404
+            if ($avconvBinary || $ffmpegBinary) {
405
+                // FIXME // a bit hacky but didn't want to use subclasses
406
+                \OC\Preview\Movie::$avconvBinary = $avconvBinary;
407
+                \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
408
+
409
+                $this->registerCoreProvider(Preview\Movie::class, '/video\/.*/');
410
+            }
411
+        }
412
+    }
413 413
 }
Please login to merge, or discard this patch.
config/config.sample.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
  */
42 42
 'instanceid' => '',
43 43
 
44
- /**
45
-  * The salt used to hash all passwords, auto-generated by the Nextcloud
46
-  * installer. (There are also per-user salts.) If you lose this salt you lose
47
-  * all your passwords. This example is for documentation only, and you should
48
-  * never use it.
49
-  *
50
-  * @deprecated This salt is deprecated and only used for legacy-compatibility,
51
-  * developers should *NOT* use this value for anything nowadays.
52
-  *
53
-  * 'passwordsalt' => 'd3c944a9af095aa08f',
54
- */
44
+    /**
45
+     * The salt used to hash all passwords, auto-generated by the Nextcloud
46
+     * installer. (There are also per-user salts.) If you lose this salt you lose
47
+     * all your passwords. This example is for documentation only, and you should
48
+     * never use it.
49
+     *
50
+     * @deprecated This salt is deprecated and only used for legacy-compatibility,
51
+     * developers should *NOT* use this value for anything nowadays.
52
+     *
53
+     * 'passwordsalt' => 'd3c944a9af095aa08f',
54
+     */
55 55
 'passwordsalt' => '',
56 56
 
57 57
 /**
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
  *   Using TLS certificates where commonName=<IP address> is deprecated
70 70
  */
71 71
 'trusted_domains' =>
72
-   [
72
+    [
73 73
     'demo.example.org',
74 74
     'otherdomain.example.org',
75 75
     '10.111.112.113',
76 76
     '[2001:db8::1]'
77
-  ],
77
+    ],
78 78
 
79 79
 
80 80
 /**
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
  *  - www.edri.org
703 703
  */
704 704
 'connectivity_check_domains' => [
705
-	'www.nextcloud.com',
706
-	'www.startpage.com',
707
-	'www.eff.org',
708
-	'www.edri.org'
705
+    'www.nextcloud.com',
706
+    'www.startpage.com',
707
+    'www.eff.org',
708
+    'www.edri.org'
709 709
 ],
710 710
 
711 711
 /**
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
  * Defaults to an empty array.
822 822
  */
823 823
 'log.condition' => [
824
-	'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9',
825
-	'users' => ['sample-user'],
826
-	'apps' => ['files'],
824
+    'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9',
825
+    'users' => ['sample-user'],
826
+    'apps' => ['files'],
827 827
 ],
828 828
 
829 829
 /**
@@ -877,18 +877,18 @@  discard block
 block discarded – undo
877 877
  *  - iOS client app id: ``1125420102``
878 878
  */
879 879
 'customclient_desktop' =>
880
-	'https://nextcloud.com/install/#install-clients',
880
+    'https://nextcloud.com/install/#install-clients',
881 881
 'customclient_android' =>
882
-	'https://play.google.com/store/apps/details?id=com.nextcloud.client',
882
+    'https://play.google.com/store/apps/details?id=com.nextcloud.client',
883 883
 'customclient_ios' =>
884
-	'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8',
884
+    'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8',
885 885
 'customclient_ios_appid' =>
886
-		'1125420102',
886
+        '1125420102',
887 887
 /**
888
- * Apps
889
- *
890
- * Options for the Apps folder, Apps store, and App code checker.
891
- */
888
+         * Apps
889
+         *
890
+         * Options for the Apps folder, Apps store, and App code checker.
891
+         */
892 892
 
893 893
 /**
894 894
  * When enabled, admins may install apps from the Nextcloud app store.
@@ -906,11 +906,11 @@  discard block
 block discarded – undo
906 906
  * indicates if a Web server can write files to that folder.
907 907
  */
908 908
 'apps_paths' => [
909
-	[
910
-		'path'=> '/var/www/nextcloud/apps',
911
-		'url' => '/apps',
912
-		'writable' => true,
913
-	],
909
+    [
910
+        'path'=> '/var/www/nextcloud/apps',
911
+        'url' => '/apps',
912
+        'writable' => true,
913
+    ],
914 914
 ],
915 915
 
916 916
 /**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
  * Defaults to ``''`` (empty string)
976 976
  */
977 977
 'preview_office_cl_parameters' =>
978
-	' --headless --nologo --nofirststartwizard --invisible --norestore '.
979
-	'--convert-to png --outdir ',
978
+    ' --headless --nologo --nofirststartwizard --invisible --norestore '.
979
+    '--convert-to png --outdir ',
980 980
 
981 981
 /**
982 982
  * Only register providers that have been explicitly enabled
@@ -1013,17 +1013,17 @@  discard block
 block discarded – undo
1013 1013
  *  - OC\Preview\Krita
1014 1014
  */
1015 1015
 'enabledPreviewProviders' => [
1016
-	'OC\Preview\PNG',
1017
-	'OC\Preview\JPEG',
1018
-	'OC\Preview\GIF',
1019
-	'OC\Preview\HEIC',
1020
-	'OC\Preview\BMP',
1021
-	'OC\Preview\XBitmap',
1022
-	'OC\Preview\MP3',
1023
-	'OC\Preview\TXT',
1024
-	'OC\Preview\MarkDown',
1025
-	'OC\Preview\OpenDocument',
1026
-	'OC\Preview\Krita',
1016
+    'OC\Preview\PNG',
1017
+    'OC\Preview\JPEG',
1018
+    'OC\Preview\GIF',
1019
+    'OC\Preview\HEIC',
1020
+    'OC\Preview\BMP',
1021
+    'OC\Preview\XBitmap',
1022
+    'OC\Preview\MP3',
1023
+    'OC\Preview\TXT',
1024
+    'OC\Preview\MarkDown',
1025
+    'OC\Preview\OpenDocument',
1026
+    'OC\Preview\Krita',
1027 1027
 ],
1028 1028
 
1029 1029
 /**
@@ -1099,11 +1099,11 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 /**
1101 1101
  * Extra SSL options to be used for configuration.
1102
-  *
1102
+ *
1103 1103
  * Defaults to an empty array.
1104 1104
  */
1105 1105
 'openssl' => [
1106
-	'config' => '/absolute/location/of/openssl.cnf',
1106
+    'config' => '/absolute/location/of/openssl.cnf',
1107 1107
 ],
1108 1108
 
1109 1109
 /**
@@ -1151,11 +1151,11 @@  discard block
 block discarded – undo
1151 1151
  * for more information.
1152 1152
  */
1153 1153
 'redis' => [
1154
-	'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock'
1155
-	'port' => 6379,
1156
-	'timeout' => 0.0,
1157
-	'password' => '', // Optional, if not defined no password will be used.
1158
-	'dbindex' => 0, // Optional, if undefined SELECT will not run and will use Redis Server's default DB Index.
1154
+    'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock'
1155
+    'port' => 6379,
1156
+    'timeout' => 0.0,
1157
+    'password' => '', // Optional, if not defined no password will be used.
1158
+    'dbindex' => 0, // Optional, if undefined SELECT will not run and will use Redis Server's default DB Index.
1159 1159
 ],
1160 1160
 
1161 1161
 /**
@@ -1184,14 +1184,14 @@  discard block
 block discarded – undo
1184 1184
  * https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1
1185 1185
  */
1186 1186
 'redis.cluster' => [
1187
-	'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
1188
-		'localhost:7000',
1189
-		'localhost:7001',
1190
-	],
1191
-	'timeout' => 0.0,
1192
-	'read_timeout' => 0.0,
1193
-	'failover_mode' => \RedisCluster::FAILOVER_ERROR,
1194
-	'password' => '', // Optional, if not defined no password will be used.
1187
+    'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
1188
+        'localhost:7000',
1189
+        'localhost:7001',
1190
+    ],
1191
+    'timeout' => 0.0,
1192
+    'read_timeout' => 0.0,
1193
+    'failover_mode' => \RedisCluster::FAILOVER_ERROR,
1194
+    'password' => '', // Optional, if not defined no password will be used.
1195 1195
 ],
1196 1196
 
1197 1197
 
@@ -1199,35 +1199,35 @@  discard block
 block discarded – undo
1199 1199
  * Server details for one or more memcached servers to use for memory caching.
1200 1200
  */
1201 1201
 'memcached_servers' => [
1202
-	// hostname, port and optional weight. Also see:
1203
-	// http://www.php.net/manual/en/memcached.addservers.php
1204
-	// http://www.php.net/manual/en/memcached.addserver.php
1205
-	['localhost', 11211],
1206
-	//array('other.host.local', 11211),
1202
+    // hostname, port and optional weight. Also see:
1203
+    // http://www.php.net/manual/en/memcached.addservers.php
1204
+    // http://www.php.net/manual/en/memcached.addserver.php
1205
+    ['localhost', 11211],
1206
+    //array('other.host.local', 11211),
1207 1207
 ],
1208 1208
 
1209 1209
 /**
1210 1210
  * Connection options for memcached
1211 1211
  */
1212 1212
 'memcached_options' => [
1213
-	// Set timeouts to 50ms
1214
-	\Memcached::OPT_CONNECT_TIMEOUT => 50,
1215
-	\Memcached::OPT_RETRY_TIMEOUT =>   50,
1216
-	\Memcached::OPT_SEND_TIMEOUT =>    50,
1217
-	\Memcached::OPT_RECV_TIMEOUT =>    50,
1218
-	\Memcached::OPT_POLL_TIMEOUT =>    50,
1213
+    // Set timeouts to 50ms
1214
+    \Memcached::OPT_CONNECT_TIMEOUT => 50,
1215
+    \Memcached::OPT_RETRY_TIMEOUT =>   50,
1216
+    \Memcached::OPT_SEND_TIMEOUT =>    50,
1217
+    \Memcached::OPT_RECV_TIMEOUT =>    50,
1218
+    \Memcached::OPT_POLL_TIMEOUT =>    50,
1219 1219
 
1220
-	// Enable compression
1221
-	\Memcached::OPT_COMPRESSION =>          true,
1220
+    // Enable compression
1221
+    \Memcached::OPT_COMPRESSION =>          true,
1222 1222
 
1223
-	// Turn on consistent hashing
1224
-	\Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
1223
+    // Turn on consistent hashing
1224
+    \Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
1225 1225
 
1226
-	// Enable Binary Protocol
1227
-	\Memcached::OPT_BINARY_PROTOCOL =>      true,
1226
+    // Enable Binary Protocol
1227
+    \Memcached::OPT_BINARY_PROTOCOL =>      true,
1228 1228
 
1229
-	// Binary serializer vill be enabled if the igbinary PECL module is available
1230
-	//\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY,
1229
+    // Binary serializer vill be enabled if the igbinary PECL module is available
1230
+    //\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY,
1231 1231
 ],
1232 1232
 
1233 1233
 
@@ -1273,61 +1273,61 @@  discard block
 block discarded – undo
1273 1273
  * One way to test is applying for a trystack account at http://trystack.org/
1274 1274
  */
1275 1275
 'objectstore' => [
1276
-	'class' => 'OC\\Files\\ObjectStore\\Swift',
1277
-	'arguments' => [
1278
-		// trystack will use your facebook id as the user name
1279
-		'username' => 'facebook100000123456789',
1280
-		// in the trystack dashboard go to user -> settings -> API Password to
1281
-		// generate a password
1282
-		'password' => 'Secr3tPaSSWoRdt7',
1283
-		// must already exist in the objectstore, name can be different
1284
-		'container' => 'nextcloud',
1285
-		// prefix to prepend to the fileid, default is 'oid:urn:'
1286
-		'objectPrefix' => 'oid:urn:',
1287
-		// create the container if it does not exist. default is false
1288
-		'autocreate' => true,
1289
-		// required, dev-/trystack defaults to 'RegionOne'
1290
-		'region' => 'RegionOne',
1291
-		// The Identity / Keystone endpoint
1292
-		'url' => 'http://8.21.28.222:5000/v2.0',
1293
-		// required on dev-/trystack
1294
-		'tenantName' => 'facebook100000123456789',
1295
-		// dev-/trystack uses swift by default, the lib defaults to 'cloudFiles'
1296
-		// if omitted
1297
-		'serviceName' => 'swift',
1298
-		// The Interface / url Type, optional
1299
-		'urlType' => 'internal'
1300
-	],
1276
+    'class' => 'OC\\Files\\ObjectStore\\Swift',
1277
+    'arguments' => [
1278
+        // trystack will use your facebook id as the user name
1279
+        'username' => 'facebook100000123456789',
1280
+        // in the trystack dashboard go to user -> settings -> API Password to
1281
+        // generate a password
1282
+        'password' => 'Secr3tPaSSWoRdt7',
1283
+        // must already exist in the objectstore, name can be different
1284
+        'container' => 'nextcloud',
1285
+        // prefix to prepend to the fileid, default is 'oid:urn:'
1286
+        'objectPrefix' => 'oid:urn:',
1287
+        // create the container if it does not exist. default is false
1288
+        'autocreate' => true,
1289
+        // required, dev-/trystack defaults to 'RegionOne'
1290
+        'region' => 'RegionOne',
1291
+        // The Identity / Keystone endpoint
1292
+        'url' => 'http://8.21.28.222:5000/v2.0',
1293
+        // required on dev-/trystack
1294
+        'tenantName' => 'facebook100000123456789',
1295
+        // dev-/trystack uses swift by default, the lib defaults to 'cloudFiles'
1296
+        // if omitted
1297
+        'serviceName' => 'swift',
1298
+        // The Interface / url Type, optional
1299
+        'urlType' => 'internal'
1300
+    ],
1301 1301
 ],
1302 1302
 
1303 1303
 /**
1304 1304
  * To use swift V3
1305 1305
  */
1306 1306
 'objectstore' => [
1307
-	'class' => 'OC\\Files\\ObjectStore\\Swift',
1308
-	'arguments' => [
1309
-		'autocreate' => true,
1310
-		'user' => [
1311
-			'name' => 'swift',
1312
-			'password' => 'swift',
1313
-			'domain' => [
1314
-				'name' => 'default',
1315
-			],
1316
-		],
1317
-		'scope' => [
1318
-			'project' => [
1319
-				'name' => 'service',
1320
-				'domain' => [
1321
-					'name' => 'default',
1322
-				],
1323
-			],
1324
-		],
1325
-		'tenantName' => 'service',
1326
-		'serviceName' => 'swift',
1327
-		'region' => 'regionOne',
1328
-		'url' => 'http://yourswifthost:5000/v3',
1329
-		'bucket' => 'nextcloud',
1330
-	],
1307
+    'class' => 'OC\\Files\\ObjectStore\\Swift',
1308
+    'arguments' => [
1309
+        'autocreate' => true,
1310
+        'user' => [
1311
+            'name' => 'swift',
1312
+            'password' => 'swift',
1313
+            'domain' => [
1314
+                'name' => 'default',
1315
+            ],
1316
+        ],
1317
+        'scope' => [
1318
+            'project' => [
1319
+                'name' => 'service',
1320
+                'domain' => [
1321
+                    'name' => 'default',
1322
+                ],
1323
+            ],
1324
+        ],
1325
+        'tenantName' => 'service',
1326
+        'serviceName' => 'swift',
1327
+        'region' => 'regionOne',
1328
+        'url' => 'http://yourswifthost:5000/v3',
1329
+        'bucket' => 'nextcloud',
1330
+    ],
1331 1331
 ],
1332 1332
 
1333 1333
 
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
  * encryption in MySQL or specify a custom wait timeout on a cheap hoster.
1380 1380
  */
1381 1381
 'dbdriveroptions' => [
1382
-	PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem',
1383
-	PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800'
1382
+    PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem',
1383
+    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800'
1384 1384
 ],
1385 1385
 
1386 1386
 /**
@@ -1437,10 +1437,10 @@  discard block
 block discarded – undo
1437 1437
  *  - pgsql (PostgreSQL)
1438 1438
  */
1439 1439
 'supportedDatabases' => [
1440
-	'sqlite',
1441
-	'mysql',
1442
-	'pgsql',
1443
-	'oci',
1440
+    'sqlite',
1441
+    'mysql',
1442
+    'pgsql',
1443
+    'oci',
1444 1444
 ],
1445 1445
 
1446 1446
 /**
@@ -1768,8 +1768,8 @@  discard block
 block discarded – undo
1768 1768
  * WARNING: only use this if you know what you are doing
1769 1769
  */
1770 1770
 'csrf.optout' => [
1771
-	'/^WebDAVFS/', // OS X Finder
1772
-	'/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive
1771
+    '/^WebDAVFS/', // OS X Finder
1772
+    '/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive
1773 1773
 ],
1774 1774
 
1775 1775
 /**
Please login to merge, or discard this patch.