mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
The new oc_previews table is optimized for storing previews and should decrease significantly the space taken by previews in the filecache table. This attend to reuse the IObjectStore abstraction over S3/Swift/Azure but currently only support one single bucket configuration. Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
90 lines
1.5 KiB
PHP
90 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace OC\Preview\Storage;
|
|
|
|
use OC\Preview\Db\Preview;
|
|
use OC\Preview\Db\PreviewMapper;
|
|
use OCP\Files\SimpleFS\ISimpleFile;
|
|
|
|
class PreviewFile implements ISimpleFile {
|
|
public function __construct(private Preview $preview, private IPreviewStorage $storage, private PreviewMapper $previewMapper) {
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getName(): string {
|
|
return $this->preview->getName();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getSize(): int|float {
|
|
return $this->preview->getSize();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getETag(): string {
|
|
return $this->preview->getEtag();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getMTime(): int {
|
|
return $this->preview->getMtime();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getContent(): string {
|
|
$stream = $this->storage->readPreview($this->preview);
|
|
return stream_get_contents($stream);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function putContent($data): void {
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function delete(): void {
|
|
$this->storage->deletePreview($this->preview);
|
|
$this->previewMapper->delete($this->preview);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getMimeType(): string {
|
|
return $this->preview->getMimetypeValue();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getExtension(): string {
|
|
return $this->preview->getExtension();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function read() {
|
|
return $this->storage->readPreview($this->preview);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function write() {
|
|
return false;
|
|
}
|
|
}
|