protected function createFromObject(SymfonyUploadedFile $file)
    {
        $path = $file->getPathname();
        $original_name = $file->getClientOriginalName();
        $mime_type = $file->getClientMimeType();
        $size = $file->getSize();
        $error = $file->getError();

        $upload_file = new UploadedFile($path, $original_name, $mime_type, $size, $error);

        // Throw error if the object is not valid
        if ($upload_file->isValid() === false) {
            throw new FileException(
                $upload_file->getErrorMessage(
                    $upload_file->getError()
                )
            );
        }

        return $upload_file;
    }