Android version #11
@ -12,6 +12,7 @@ import {
|
|||||||
type ShareEvent,
|
type ShareEvent,
|
||||||
} from "tauri-plugin-sharetarget-api";
|
} from "tauri-plugin-sharetarget-api";
|
||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
|
import { sendImage, sendImageFile } from "./network";
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const [logs, setLogs] = createSignal<string[]>([]);
|
const [logs, setLogs] = createSignal<string[]>([]);
|
||||||
@ -54,6 +55,15 @@ export const App = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
const f = file();
|
||||||
|
if (f == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendImageFile(f.name, f);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ImageViewer />
|
<ImageViewer />
|
||||||
|
@ -48,6 +48,23 @@ const sendImageResponseValidator = strictObject({
|
|||||||
Status: string(),
|
Status: string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const sendImageFile = async (
|
||||||
|
imageName: string,
|
||||||
|
file: File,
|
||||||
|
): Promise<InferOutput<typeof sendImageResponseValidator>> => {
|
||||||
|
const request = getBaseAuthorizedRequest({
|
||||||
|
path: `image/${imageName}`,
|
||||||
|
body: file,
|
||||||
|
method: "POST",
|
||||||
|
});
|
||||||
|
|
||||||
|
request.headers.set("Content-Type", "application/oclet-stream");
|
||||||
|
|
||||||
|
const res = await fetch(request).then((res) => res.json());
|
||||||
|
|
||||||
|
return parse(sendImageResponseValidator, res);
|
||||||
|
};
|
||||||
|
|
||||||
export const sendImage = async (
|
export const sendImage = async (
|
||||||
imageName: string,
|
imageName: string,
|
||||||
base64Image: string,
|
base64Image: string,
|
||||||
|
Reference in New Issue
Block a user