com\setasign\SetaFramework\FileSystem

SavedFile Class SavedFile

File: /SetaFramework/src/FileSystem/SavedFile.php

This class represent a file within the filesystem.

Class hierarchy

Implements

Summary

Properties

$contentType

protected string SavedFile::$contentType

$fileName

protected string SavedFile::$fileName

$filePath


Static Methods

createByUploadedFile()

public static SavedFile::createByUploadedFile (
\Psr\Http\Message\UploadedFileInterface $uploadedFile,
string $targetPath
): SavedFile

This method will create a saved file instance by using moveTo().

Parameters
$uploadedFile : \Psr\Http\Message\UploadedFileInterface
 
$targetPath : string
 
Exceptions

Throws \com\setasign\SetaFramework\Request\UploadException If the $uploadedFile has an error.

See
  • \Psr\Http\Message\UploadedFileInterface::moveTo()

Methods

__construct()

public SavedFile::__construct (
string $fileName,
string $contentType,
string $filePath
)

SavedFile constructor.

Parameters
$fileName : string
 
$contentType : string
 
$filePath : string
 

export()

public SavedFile::export (
bool $asString = false
): UnsavedFile

Will export the saved file as unsaved file.

Parameters
$asString : bool

If true the file will be read immediately and the content will be kept in the memory. Otherwise the file will be read as a stream.

Exceptions

Throws \com\setasign\SetaFramework\Exception If the file cannot be read.

getContentType()

public SavedFile::getContentType (
void
): string

Get the content type.

getFileContent()

Get the content of the file.

getFileContentAsStream()

getFileContentAsString()

getFileName()

public SavedFile::getFileName (
void
): string

Get the file name

getFilePath()

public SavedFile::getFilePath (
void
): string

getFileSize()

public SavedFile::getFileSize (
void
): int

withFileName()

public SavedFile::withFileName (
string $newFileName
): File

Returns a new instance of the file with another file name.

Parameters
$newFileName : string