starting upload functions
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
FROM node:lts AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV DATABASE_URL=postgresql://memento:test@localhost:5432/memento
|
||||
ENV UPLOAD_DIR=/data/images
|
||||
|
||||
RUN npm install
|
||||
RUN npx drizzle-kit push
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
@@ -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
38
src/utils/quill.ts
Normal 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) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user