Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
FreezaSama authored Jan 3, 2025
1 parent 742e8ad commit d5e9fd4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ <h1>AI FORGE</h1>

// Upload sketch
const sketchFormData = new FormData();
const sketchBlob = await fetch(sketchData).then(r => r.blob());
function dataURLtoBlob(dataURL) {
const [header, base64] = dataURL.split(',');
const mimeString = header.match(/:(.*?);/)[1];
const byteString = atob(base64);
const arrayBuffer = new Uint8Array(byteString.length);
for (let i = 0; i < byteString.length; i++) {
arrayBuffer[i] = byteString.charCodeAt(i);
}
return new Blob([arrayBuffer], { type: mimeString });
}

const sketchBlob = dataURLtoBlob(sketchData);
sketchFormData.append('image', sketchBlob, 'sketch.png');

console.log('Uploading sketch to ComfyUI...');
Expand Down

0 comments on commit d5e9fd4

Please sign in to comment.