protected function _createObject( $args = array() ) {
		if ( empty( $args['post_mime_type'] ) ) {
			if ( ! empty( $args['file'] ) && is_readable( $args['file'] ) ) {
				$this->_debug( 'Reading mime type of the file: ' . $args['file'] );

				$filetype = wp_check_filetype( basename( $args['file'] ), null );
				if ( ! empty( $filetype['type'] ) ) {
					$args['post_mime_type'] = $filetype['type'];
					$this->_debug( 'Mime type found: ' . $filetype['type'] );
				} else {
					$this->_debug( 'Mime type not found' );
				}
			}
		}

		$attachment_id = wp_insert_attachment( $args );
		if ( $attachment_id ) {
			$this->_debug(
				'Generated attachment ID: %d (file: %s)',
				$attachment_id,
				! empty( $args['file'] ) ? $args['file'] : 'not-provided'
			);

			$this->_debug( 'Generating attachment metadata' );
			$metadata = wp_generate_attachment_metadata( $attachment_id, $args['file'] );
			if ( is_wp_error( $metadata ) ) {
				$this->_debug(
					'Attachment metadata generation failed with error [%s] %s',
					$metadata->get_error_code(),
					$metadata->get_error_message()
				);
			} elseif ( empty( $metadata ) ) {
				$this->_debug( 'Attachment metadata generation failed' );
			} else {
				wp_update_attachment_metadata( $attachment_id, $metadata );
			}
		} else {
			$this->_debug( 'Attachment generation failed' );
		}

		return $attachment_id;
	}