newwebsouth/upload

There is no license information available for the latest version (1.1.1) of this package.

Component of upload

1.1.1 2020-10-06 21:08 UTC

README

The upload Manager help you for upload a file.

Configuration:

config/components/Upload.php

return [

&nbsp;&nbsp;&nbsp;&nbsp;'config_name' => [ <br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::PATH => '/var/sample/dir/',<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::MAX_FILE_SIZE => 100000,<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::ACCEPT_TYPE => [<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type_1',<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type_2',<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::DUPLICATION_RULE => 'closure|string : iteration| string : overwrite| string : crash',<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::WAIT_TRANSACTION => false|true
&nbsp;&nbsp;&nbsp;&nbsp;]<br>

]

For DUPLICATION_RULE

Closure: function(string $originalName){ ... }

"iteration": A number will be added to filename:

test.png = test(1).png

"overwrite": The file will be overwriting

"crash": You will receive a Newwebsouth\Upload\Exception\UploadDuplicationException::class

For WAIT_TRANSACTION

If true, the file will be upload when the transaction have success

Mappe the interface in container configuration

Method

upload(array $part, string $configurationName): array

return a metadata of document:

return [

&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::META_LOCAL_PATH  => $path,<br>
&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::META_PUBLIC_PATH => public path (if is public ressource),<br>
&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::META_SIZE => size of document,<br>
&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::META_SHORT_NAME_WITH_EXTENSION    => filename with extension,<br>
&nbsp;&nbsp;&nbsp;&nbsp;UploadManagerInterface::META_SHORT_NAME_WITHOUT_EXTENSION => filename without extension<br>

]