mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 18:11:41 -04:00
fix(files): Always return a valid mimetype
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
a0fd63155b
commit
f5e3e97ea6
9 changed files with 11 additions and 20 deletions
|
|
@ -69,7 +69,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 {
|
||||
|
|
|
|||
|
|
@ -60,10 +60,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
|
||||
|
|
|
|||
|
|
@ -43,10 +43,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
|
||||
|
|
|
|||
|
|
@ -103,10 +103,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