Add comments and stuff

This commit is contained in:
city-unit
2023-08-20 00:15:57 -04:00
parent 24da113670
commit 3ce8343016
4 changed files with 63 additions and 1 deletions

View File

@ -555,6 +555,16 @@ export function extractDataFromPng(data, identifier = 'chara') {
}
}
/**
* Sends a base64 encoded image to the backend to be saved as a file.
*
* @param {string} base64Data - The base64 encoded image data.
* @param {string} characterName - The character name to determine the sub-directory for saving.
* @param {string} ext - The file extension for the image (e.g., 'jpg', 'png', 'webp').
*
* @returns {Promise<string>} - Resolves to the saved image's path on the server.
* Rejects with an error if the upload fails.
*/
export async function saveBase64AsFile(base64Data, characterName, ext) {
// Construct the full data URL
const format = ext; // Extract the file extension (jpg, png, webp)