mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #31418 from nextcloud/enh/simple-file-extension
This commit is contained in:
commit
232af474a8
4 changed files with 36 additions and 1 deletions
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ use OCP\Files\NotFoundException;
|
|||
use OCP\Files\NotPermittedException;
|
||||
|
||||
/**
|
||||
* Interface ISimpleFile
|
||||
* This interface allows to manage simple files.
|
||||
*
|
||||
* This interface must not be implemented in your application but
|
||||
* instead should be used as a service and injected in your code with
|
||||
* dependency injection.
|
||||
*
|
||||
* @since 11.0.0
|
||||
*/
|
||||
|
|
@ -102,6 +106,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,14 @@ class InMemoryFile implements ISimpleFile {
|
|||
return $fileInfo->buffer($this->contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function getExtension(): string {
|
||||
return \pathinfo($this->name, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream reading is unsupported for in memory files.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue