mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
fix(files): Always return a valid mimetype
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
376b7e8bbd
commit
8d8f94b8ce
9 changed files with 17 additions and 20 deletions
|
|
@ -70,7 +70,7 @@ class TrashItem implements ITrashItem {
|
|||
return $this->fileInfo->getPath();
|
||||
}
|
||||
|
||||
public function getMimetype() {
|
||||
public function getMimetype(): string {
|
||||
return $this->fileInfo->getMimetype();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ class CacheEntry implements ICacheEntry {
|
|||
}
|
||||
|
||||
|
||||
public function getMimeType() {
|
||||
return $this->data['mimetype'];
|
||||
public function getMimeType(): string {
|
||||
return $this->data['mimetype'] ?? 'application/octet-stream';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -133,11 +133,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
|
|||
return isset($this->data['fileid']) ? (int)$this->data['fileid'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimetype() {
|
||||
return $this->data['mimetype'];
|
||||
public function getMimetype(): string {
|
||||
return $this->data['mimetype'] ?? 'application/octet-stream';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -314,10 +314,7 @@ class LazyFolder implements Folder {
|
|||
return $this->__call(__FUNCTION__, func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getMimetype() {
|
||||
public function getMimetype(): string {
|
||||
if (isset($this->data['mimetype'])) {
|
||||
return $this->data['mimetype'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ class Node implements INode {
|
|||
return $this->getFileInfo(false)->isShared();
|
||||
}
|
||||
|
||||
public function getMimeType() {
|
||||
public function getMimeType(): string {
|
||||
return $this->getFileInfo(false)->getMimetype();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class NonExistingFile extends File {
|
|||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
public function getMimeType() {
|
||||
public function getMimeType(): string {
|
||||
if ($this->fileInfo) {
|
||||
return parent::getMimeType();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace OCP\Files\Cache;
|
||||
|
||||
use ArrayAccess;
|
||||
use OCP\AppFramework\Attribute\Consumable;
|
||||
|
||||
/**
|
||||
* meta data for a file or folder
|
||||
|
|
@ -19,6 +20,7 @@ use ArrayAccess;
|
|||
* implemented it in the private implementation. Hence php would allow using the
|
||||
* object as array, while strictly speaking it didn't support this.
|
||||
*/
|
||||
#[Consumable(since: '9.0.0')]
|
||||
interface ICacheEntry extends ArrayAccess {
|
||||
/**
|
||||
* @since 9.0.0
|
||||
|
|
@ -60,10 +62,9 @@ interface ICacheEntry extends ArrayAccess {
|
|||
/**
|
||||
* Get the full mimetype
|
||||
*
|
||||
* @return string
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function getMimeType();
|
||||
public function getMimeType(): string;
|
||||
|
||||
/**
|
||||
* Get the first part of the mimetype
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace OCP\Files;
|
||||
|
||||
use OCP\AppFramework\Attribute\Consumable;
|
||||
use OCP\Lock\LockedException;
|
||||
|
||||
/**
|
||||
|
|
@ -17,6 +18,7 @@ use OCP\Lock\LockedException;
|
|||
*
|
||||
* @since 6.0.0
|
||||
*/
|
||||
#[Consumable(since: '6.0.0')]
|
||||
interface File extends Node {
|
||||
/**
|
||||
* Get the content of the file as string
|
||||
|
|
@ -43,10 +45,9 @@ interface File extends Node {
|
|||
/**
|
||||
* Get the mimetype of the file
|
||||
*
|
||||
* @return string
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function getMimeType();
|
||||
public function getMimeType(): string;
|
||||
|
||||
/**
|
||||
* Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
namespace OCP\Files;
|
||||
|
||||
use OCP\AppFramework\Attribute\Consumable;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +15,7 @@ use OCP\Files\Storage\IStorage;
|
|||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
#[Consumable(since: '7.0.0')]
|
||||
interface FileInfo {
|
||||
/**
|
||||
* @since 7.0.0
|
||||
|
|
@ -103,10 +105,9 @@ interface FileInfo {
|
|||
/**
|
||||
* Get the full mimetype of the file or folder i.e. 'image/png'
|
||||
*
|
||||
* @return string
|
||||
* @since 7.0.0
|
||||
*/
|
||||
public function getMimetype();
|
||||
public function getMimetype(): string;
|
||||
|
||||
/**
|
||||
* Get the first part of the mimetype of the file or folder i.e. 'image'
|
||||
|
|
|
|||
Loading…
Reference in a new issue