Releases: GravityPDF/Upload
Releases · GravityPDF/Upload
3.1.0
v3.0.1
What's Changed
- Resolve ArrayAccess deprecation warning in PHP 8.1 by @jakejackson1 in #15
- Add PHP8.2 to automated test suite by @jakejackson1 in #16
Full Changelog: 3.0.0...3.0.1
v3.0.0
Upload 3.0.0
Breaking Changes
- Revert removal of
\GravityPdf\Upload\File::__call()magic method in 2.0.0, restoring API functionality to match v1 - Add
setNameWithExtension()method to\GravityPdf\Upload\FileInfoInterface - Change signature of
\GravityPdf\Upload\FileInfoInterface::setName(string $name) - Change signature of
\GravityPdf\Upload\FileInfoInterface::setExtension(string $extension) - Remove
\GravityPdf\Upload\Validation\Dimensionsvalidation class - Minimum PHP now 7.3 or higher
v2.0.0
Upload 2.0
Breaking Changes
- PHP 7.3+ (previously PHP5.3+)
- Namespace Change:
\Upload->\GravityPdf\Upload - Sanitize Filename and Extension: replace invalid/unsafe/reserved characters/words, trim, prevent < 255 byte filenames. See the unit tests for the expected transformations.
- Remove
\GravityPdf\Upload\File::__call()magic method which would call the underlyingFileInfoInterfaceobject(s) and return the result as a string or array. Useforeach($file as FileInfoInterface $fileInfo) { ... }instead. - Changed return value of
\GravityPdf\Upload\Storage\FileSystem::upload()to the destination file pathstring(previouslyvoid) - Strict type support added
- Replace
\Upload\Exception\UploadExceptionwith\GravityPdf\Upload\Excelption \GravityPdf\Upload\Fileno longer extends\SplFileInfo- Signature of
\GravityPdf\Upload\File::__construct()changed to__construct(string $key, \GravityPdf\Upload\StorageInterface $storage) - Signature of
\GravityPdf\Upload\File::addValidations()changed toaddValidations(array $validations). Use newaddValidation(\GravityPdf\Upload\ValidationInterface $validation)method to add single validation. \GravityPdf\Upload\File::validate()was replaced by\GravityPdf\Upload\File::isValid()- Signature of
\GravityPdf\Upload\File::upload($newName = null)changed toupload(). Use\GravityPdf\Upload\File::setName(string $name)or\GravityPdf\Upload\File::setNameWithExtension(string $name)before callingupload()to change the file name. \Upload\Storage\Basehas been removed and\GravityPdf\Upload\Storage\FileSysteminstead implements\GravityPdf\Upload\StorageInterface- Signature of
\Upload\Storage\FileSystem::upload(\Upload\File $file, $newName = null)changed to\GravityPdf\Upload\Storage\FileSystem::upload(\GravityPdf\Upload\FileInfoInterface $fileInfo) \Upload\Validation\Basehas been removed and\GravityPdf\Upload\Validation/*classes instead implements\GravityPdf\Upload\ValidationInterface- Classes that implement
\GravityPdf\Upload\ValidationInterfacemust havevalidatemethod with the signaturevalidate(\Upload\FileInfoInterface $fileInfo)and this method should throw the exception\GravityPdf\Upload\Exceptionif the file has failed validation
New Features
- Support for UTF-8 Filenames
- Enhanced file name and extension sanitizing (you still need to escape HTML on output or when inserting into database)
- Added
\GravityPdf\Upload\FileInfo::setNameWithExtension(string $name)(instead of usingsetName()andsetExtension()separately) - Added
\GravityPdf\Upload\Storage\FileSystem::getDirectory()to return directory that has been set - Added
beforeValidation(callable $callable),afterValidation(callable $callable),beforeUpload(callable $callable), andafterUpload(callable $callable)to\GravityPdf\Upload\File. The callable will receive a\GravityPdf\Upload\FileInfoInterfaceobject as the first parameter. \GravityPdf\Upload\Fileimplements\ArrayAccess, \IteratorAggregate, \Countablewhich allows you to treatFileas an array and access the underlying\GravityPdf\Upload\FileInfoobjects to get info about each individual file for the current$key. This is useful if your file upload HTML field accepts multiple files.- Added
\GravityPdf\Upload\FileInfoInterfaceand\GravityPdf\Upload\FileInfoobjects to represent each individual image. The methods include:getPathname()getName()setName(string $name)getExtension()setExtension(string $extension)getNameWithExtension()setNameWithExtension(string $filename)getMimetype()getSize()getMd5()getDimensions()isUploadedFile()
Bug Fixes
- Resolved PHP 8.1 warnings