StorageService
in package
Table of Contents
Properties
Methods
- __construct() : mixed
- asUploadedFile() : UploadedFile
- attach() : void
- copy() : StorageFile
- createFile() : StorageFile
- deleteAll() : void
- deleteFile() : void
- disk() : Filesystem
- down() : void
- download() : StreamedResponse
- Create a streamed download response for a given file.
- get() : string
- Get file content.
- getAs() : string
- Get content of storage file to temporary file and return its path.
- getByOriginals() : Collection<string|int, StorageFile>
- getExt() : string|null
- getFile() : StorageFile|null
- getMimeType() : string|null
- getOrigin() : StorageFile
- getTarget() : string
- getUrl() : string|null
- getUrls() : array<string|int, mixed>|null
- get list of urls of all variants.
- put() : string|bool
- Write the contents of a file.
- putFile() : string|false
- Store the uploaded file on the disk.
- putFileAs() : StorageFile
- Put a local file to cloud storage.
- removeTap() : void
- Create a new storage.
- rollDown() : void
- rollUp() : void
- tap() : void
- Create a new storage.
- copyFile() : StorageFile|null
Properties
$diskRepository
private
DiskRepositoryInterface
$diskRepository
$fileRepository
private
FileRepositoryInterface
$fileRepository
Methods
__construct()
public
__construct(FileRepositoryInterface $fileRepository, DiskRepositoryInterface $diskRepository) : mixed
Parameters
- $fileRepository : FileRepositoryInterface
- $diskRepository : DiskRepositoryInterface
asUploadedFile()
public
asUploadedFile(mixed $id) : UploadedFile
Parameters
- $id : mixed
Return values
UploadedFileattach()
public
attach(array<string|int, mixed> $idMap, mixed $itemId, mixed $itemType) : void
Parameters
- $idMap : array<string|int, mixed>
- $itemId : mixed
- $itemType : mixed
copy()
public
copy(int|StorageFile $file) : StorageFile
Parameters
- $file : int|StorageFile
Return values
StorageFilecreateFile()
public
createFile(array<string|int, mixed> $attributes) : StorageFile
Parameters
- $attributes : array<string|int, mixed>
Return values
StorageFiledeleteAll()
public
deleteAll(mixed $fileId) : void
Parameters
- $fileId : mixed
Tags
deleteFile()
public
deleteFile(mixed $fileId, string|null $variant) : void
Parameters
- $fileId : mixed
- $variant : string|null
Tags
disk()
public
disk(string $name) : Filesystem
Parameters
- $name : string
Return values
Filesystemdown()
public
down(mixed $id) : void
Parameters
- $id : mixed
download()
Create a streamed download response for a given file.
public
download(int|StorageFile $file[, string|null $name = null ][, array<string|int, mixed> $headers = [] ]) : StreamedResponse
Parameters
- $file : int|StorageFile
- $name : string|null = null
- $headers : array<string|int, mixed> = []
Return values
StreamedResponseget()
Get file content.
public
get(int|StorageFile $id) : string
Parameters
- $id : int|StorageFile
Return values
stringgetAs()
Get content of storage file to temporary file and return its path.
public
getAs(int|StorageFile $file) : string
Parameters
- $file : int|StorageFile
-
Storage file id
Return values
string —Path of temporary file.
getByOriginals()
public
getByOriginals(int $id) : Collection<string|int, StorageFile>
Parameters
- $id : int
Return values
Collection<string|int, StorageFile>getExt()
public
getExt(int $id) : string|null
Parameters
- $id : int
Return values
string|nullgetFile()
public
getFile(mixed $id) : StorageFile|null
Parameters
- $id : mixed
Return values
StorageFile|nullgetMimeType()
public
getMimeType(int $id) : string|null
Parameters
- $id : int
Return values
string|nullgetOrigin()
public
getOrigin(int $id) : StorageFile
Parameters
- $id : int
Return values
StorageFilegetTarget()
public
getTarget(mixed $diskId) : string
Parameters
- $diskId : mixed
Return values
stringgetUrl()
public
getUrl(mixed $id) : string|null
Parameters
- $id : mixed
Return values
string|nullgetUrls()
get list of urls of all variants.
public
getUrls(int $id) : array<string|int, mixed>|null
Parameters
- $id : int
Return values
array<string|int, mixed>|nullput()
Write the contents of a file.
public
put(string $storage, string $path, StreamInterface|File|UploadedFile|string|resource $contents[, mixed $options = [] ]) : string|bool
Parameters
- $storage : string
- $path : string
- $contents : StreamInterface|File|UploadedFile|string|resource
- $options : mixed = []
Return values
string|boolputFile()
Store the uploaded file on the disk.
public
putFile(string $storage, string $path, File|UploadedFile|string $file[, mixed $options = [] ]) : string|false
Parameters
- $storage : string
- $path : string
- $file : File|UploadedFile|string
- $options : mixed = []
Return values
string|falseputFileAs()
Put a local file to cloud storage.
public
putFileAs(string $storageId, string $path, string|UploadedFile $file, string $name[, array<string|int, mixed> $extra = [] ][, array<string|int, mixed> $options = ['visibility' => 'public'] ]) : StorageFile
Parameters
- $storageId : string
-
Storage id. Example "photo", "video", "attachment", ...
- $path : string
-
Could storage directory etc: "photo/2012/06/14"
- $file : string|UploadedFile
-
Realpath of local
- $name : string
-
Realpath of
- $extra : array<string|int, mixed> = []
-
Extra information of storage file to storage_files table
- $options : array<string|int, mixed> = ['visibility' => 'public']
-
Storage options, etc: ['visibility'=> 'public']
Return values
StorageFileremoveTap()
Create a new storage.
public
removeTap(string $name) : void
Parameters
- $name : string
Tags
rollDown()
public
rollDown(mixed $id) : void
Parameters
- $id : mixed
rollUp()
public
rollUp(mixed $id, mixed $storageId) : void
Parameters
- $id : mixed
- $storageId : mixed
tap()
Create a new storage.
public
tap(string $name[, array<string|int, mixed> $attributes = [] ]) : void
Parameters
- $name : string
- $attributes : array<string|int, mixed> = []
-
['name'=>string, 'target_id'=>string]
Tags
copyFile()
private
copyFile(StorageFile $from[, StorageFile|null $origin = null ]) : StorageFile|null
Parameters
- $from : StorageFile
- $origin : StorageFile|null = null