Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!] Refactor support for values in file properties
Improve support for multilingual/multiple values across various methods of FileProperty. Validation will now (correctly) log a message if a value (a file) is missing, is unparsable, is a rejected MIME type, or exceeds a maximum file size. Breaking Changes: - Removed deprecated accessor methods in favour of get-prefix variants - Refactored validation methods to focus on values (files) directly - Moved default MIME types to allow overriding in media-specific properties Added: - Option "fallbackFilename" to customize generated filename (defaults to property label) - Method `hasAcceptedMimetypes()` to check if any custom or fallback MIME types are specified - Method `getDefaultAcceptedMimetypes()` to distinguish between custom and fallback MIME types in property variants like ImageProperty and AudioProperty - Method `assertValidUploadPath()` to ensure upload path exists (or creates it) and checks if writable - Methods `isAcceptedMimeType()` and `isAcceptedFilesize()` - Methods `generateExtensionFromFile()`, `generateExtensionFromMimeType()`, and `resolveExtensionFromMimeType()` - Method `formatFilesize()` to format bytes into a human-readable unit - Method `pathFor()` to make an absolute path to a directory or file - Method `parseValAsFileList()` to flatten value object to simplify validation and parsing of values Removed: - Aliases `filesize()`, `mimetype()`, `mimetypeFor()` in favour of their get-prefixed methods Changed: - Bump branch-alias to 0.11 - Moved default MIME types from `getAcceptedMimeTypes()` to new `getDefaultAcceptedMimetypes()` for ImageProperty and AudioProperty - Fallback in method `getMimetype()` to retrieve the MIME type of the first value - Fallback in method `getFilesize()` to retrieve the MIME type of the first value - Renamed validation methods and internal routines to validate MIME type and size of available values (ignoring `getMimetype()` and `getFilesize`) - Unified methods `dataUpload()` and `fileUpload()` to throw exceptions - Unified methods `saveDataUploads()` and `saveDataUploads()` to catch exceptions and log errors - Replaced validation methods with new `isAccepted*()` methods inside `dataUpload()` and `fileUpload()` - Method `dataUpload()` to generate filename and extension before calling `uploadTarget()` - Method `uploadTarget()` to simplify making of filename - Method `generateFilename()` to use "fallbackFilename" and sanitize value Fixed: - Edge case where MIME type resolution returns "inode/x-empty" or empty string - Edge cases where a string is expected
- Loading branch information