starting upload functions

This commit is contained in:
2026-01-13 10:27:33 +13:00
parent cf5801689f
commit 03d8c2ff74
4 changed files with 42 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import { integer, pgTable, varchar, date, json } from "drizzle-orm/pg-core";
export const entryTable = pgTable("entries", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
data: date().defaultNow(),
date: varchar().notNull(),
location: json(),
content: json(),
});

View File

@@ -8,7 +8,6 @@ import "../styles/global.css"
const quill = new Quill('#editor', {
modules: {
toolbar: [
// [{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image'],
],

38
src/utils/quill.ts Normal file
View File

@@ -0,0 +1,38 @@
import { db } from "./db";
import type { Delta } from "quill";
export interface Entry {
date: string,
location: { lat: number, long: number } | null,
content: Delta
}
// ty https://stackoverflow.com/questions/35940290
function dataURLtoFile(dataurl: string, filename: string) {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[arr.length - 1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {type:mime});
}
async function uploadImages(delta: Delta) {
let newDelta = delta
for (const value in newDelta.ops) {
}
const data = new FormData()
data.append('image', dataURLtoFile('image.jpg', 'a'))
}
export async function uploadDelta(entry: Entry) {
}