std::string fileToBase64()

in image/image.cpp [85:99]


std::string fileToBase64(const std::string& filePath) {
	// Open the file in binary mode
	std::ifstream file(filePath, std::ios::binary);
	if (!file.is_open()) {
		throw std::runtime_error("Could not open file: " + filePath);
	}

	// Read the file into a byte vector
	std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(file), {});

	// Encode the byte vector to base64
	std::string base64String = base64_encode(buffer);

	return base64String;
}