starting upload functions
This commit is contained in:
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