feat: sending images and receiving them is now working
This commit is contained in:
@ -24,6 +24,8 @@ func SaveImageToProcess(userId string, imageName string, imageData []byte) (mode
|
||||
|
||||
stmt := UserImagesToProcess.INSERT(UserImagesToProcess.UserID, UserImagesToProcess.ImageID).VALUES(userId, image.ID).RETURNING(UserImagesToProcess.AllColumns)
|
||||
|
||||
fmt.Println(stmt.DebugSql())
|
||||
|
||||
userImage := model.UserImagesToProcess{}
|
||||
err = stmt.Query(db, &userImage)
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { createSignal } from "solid-js";
|
||||
import { createEffect, createResource, createSignal, For } from "solid-js";
|
||||
import { Search } from "@kobalte/core/search";
|
||||
import { IconSearch, IconRefresh } from "@tabler/icons-solidjs";
|
||||
import clsx from "clsx";
|
||||
import { ImageViewer } from "./components/ImageViewer";
|
||||
import { getUserImages } from "./network";
|
||||
import { image } from "@tauri-apps/api";
|
||||
|
||||
type Emoji = {
|
||||
emoji: string;
|
||||
@ -13,6 +15,12 @@ function App() {
|
||||
const [options, setOptions] = createSignal<Emoji[]>([]);
|
||||
const [emoji, setEmoji] = createSignal<Emoji | null>(null);
|
||||
|
||||
const [images] = createResource(getUserImages);
|
||||
|
||||
createEffect(() => {
|
||||
console.log(images()?.map(image => image.ID))
|
||||
});
|
||||
|
||||
const emojiData: Emoji[] = [
|
||||
{ emoji: "😀", name: "Grinning Face" },
|
||||
{ emoji: "😃", name: "Grinning Face with Big Eyes" },
|
||||
@ -97,6 +105,11 @@ function App() {
|
||||
<div class="col-span-3 row-span-3 bg-blue-200 rounded-xl" />
|
||||
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
||||
<div class="col-span-6 row-span-3 bg-yellow-200 rounded-xl" />
|
||||
<For each={images()}>
|
||||
{(image) => (
|
||||
<img src={`http://localhost:3040/image/${image.ID}`} class="col-span-3 row-span-3 rounded-xl" />
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,10 +12,8 @@ export function ImageViewer() {
|
||||
console.log("Received processed PNG", event);
|
||||
const base64Data = event.payload as string;
|
||||
|
||||
const urlImage = `data:image/png;base64,${base64Data}`;
|
||||
setLatestImage(urlImage);
|
||||
|
||||
sendImage("test-image.png", urlImage);
|
||||
setLatestImage(`data:image/png;base64,${base64Data}`);
|
||||
sendImage("test-image.png", base64Data);
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
@ -32,16 +32,15 @@ const sendImageResponseValidator = object({
|
||||
|
||||
export const sendImage = async (
|
||||
imageName: string,
|
||||
image: BlobPart,
|
||||
base64Image: string,
|
||||
): Promise<InferOutput<typeof sendImageResponseValidator>> => {
|
||||
const data = new Blob([image]);
|
||||
const request = getBaseRequest({
|
||||
path: `image/${imageName}`,
|
||||
body: data,
|
||||
body: base64Image,
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
request.headers.set("Content-Type", "aplication/base64");
|
||||
request.headers.set("Content-Type", "application/base64");
|
||||
|
||||
const res = await fetch(request).then((res) => res.json());
|
||||
|
||||
|
Reference in New Issue
Block a user