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

@@ -1,9 +1,12 @@
FROM node:lts AS runtime FROM node:lts AS runtime
WORKDIR /app WORKDIR /app
VOLUME [ "/data" ]
COPY . . COPY . .
ENV DATABASE_URL=postgresql://memento:test@localhost:5432/memento ENV DATABASE_URL=postgresql://memento:test@localhost:5432/memento
ENV UPLOAD_DIR=/data/images
RUN npm install RUN npm install
RUN npx drizzle-kit push RUN npx drizzle-kit push

View File

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

View File

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