Documentation

FileStorage
in package

File storage service. This service can be used to safely store files without having to worry about file names.

Table of Contents

Properties

$storageConfig  : array<string|int, mixed>
$translator  : Translator
$watermarkService  : WatermarkService

Methods

__construct()  : mixed
downloadFile()  : Stream|null
Returns a response suitable for offering a file download.
generateStoragePath()  : string
Generates CFS paths.
removeFile()  : bool
Removes a file from the content based file system.
storeFile()  : string
Stores files in the content based file system.
storeUploadedFile()  : string
Stores an uploaded file in the content based file system.

Properties

$storageConfig read-only

private array<string|int, mixed> $storageConfig

$translator read-only

private Translator $translator

Methods

__construct()

public __construct(Translator $translator, array<string|int, mixed> $storageConfig, WatermarkService $watermarkService) : mixed
Parameters
$translator : Translator
$storageConfig : array<string|int, mixed>
$watermarkService : WatermarkService
Tags
phpcsSuppress

SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification

downloadFile()

Returns a response suitable for offering a file download.

public downloadFile(string $path, string $fileName[, bool $watermarkPdf = false ][, bool $scanned = false ]) : Stream|null

In most modern browsers this function will cause the browser to display the file and give the user the option to save it.

Parameters
$path : string

The CFS path of the file to download

$fileName : string

The file name to give the downloaded file

$watermarkPdf : bool = false

Parameter to require addition of a watermark to the pdf before download

$scanned : bool = false
Return values
Stream|null

If the given file is not found, null is returned

generateStoragePath()

Generates CFS paths.

public generateStoragePath(string $path[, string $directory = '' ]) : string
Parameters
$path : string

The path of the photo to generate the path for

$directory : string = ''
Return values
string

the path at which the photo should be saved

removeFile()

Removes a file from the content based file system.

public removeFile(string $path) : bool
Parameters
$path : string

The CFS path of the file to remove

Return values
bool

indicating if removing the file was successful

storeFile()

Stores files in the content based file system.

public storeFile(string $source[, bool $move = true ]) : string
Parameters
$source : string

The source file to store

$move : bool = true

indicating whether the file should be moved or copied

Return values
string

the path at which the file was stored

storeUploadedFile()

Stores an uploaded file in the content based file system.

public storeUploadedFile(array<string|int, mixed> $file[, string $directory = '' ]) : string
Parameters
$file : array<string|int, mixed>
$directory : string = ''
Tags
psalm-param

array{ name: string, tmp_name: string, error: int, } $file

throws
Exception
Return values
string

The CFS path at which the file was stored


        
On this page

Search results