mirror of
https://github.com/nextcloud/server.git
synced 2024-09-01 17:54:51 +02:00
Extend simple file with extension getter
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
f1604cf7af
commit
0571391b10
@ -190,6 +190,17 @@ class NewSimpleFile implements ISimpleFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getExtension(): string {
|
||||
if ($this->file) {
|
||||
return $this->file->getExtension();
|
||||
} else {
|
||||
return \pathinfo($this->name, PATHINFO_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
|
||||
*
|
||||
|
@ -158,6 +158,13 @@ class SimpleFile implements ISimpleFile {
|
||||
return $this->file->getMimeType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getExtension(): string {
|
||||
return $this->file->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
|
||||
*
|
||||
|
@ -102,6 +102,11 @@ interface ISimpleFile {
|
||||
*/
|
||||
public function getMimeType();
|
||||
|
||||
/**
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function getExtension(): string;
|
||||
|
||||
/**
|
||||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
|
||||
*
|
||||
|
@ -126,6 +126,13 @@ class InMemoryFile implements ISimpleFile {
|
||||
return $fileInfo->buffer($this->contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getExtension(): string {
|
||||
return \pathinfo($this->name, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream reading is unsupported for in memory files.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user