implemented file upload
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from "react"
|
||||
import { useState } from "react"
|
||||
import uploadFile from "../functions/uploadFile"
|
||||
import { useOpenDirQuery } from "../generated/graphql"
|
||||
import Breadcrum from "./Breadcrum"
|
||||
import DragAndDrop from "./DragAndDrop"
|
||||
@@ -17,17 +18,22 @@ const FileBrowser: React.FC = () => {
|
||||
}
|
||||
})
|
||||
|
||||
function handleDrop(files:FileList) {
|
||||
async function handleDrop(files:FileList) {
|
||||
const wait: Promise<boolean>[] = []
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
console.debug(file) // TODO
|
||||
wait.push(uploadFile(file, path + file.name))
|
||||
}
|
||||
|
||||
await Promise.all(wait)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DragAndDrop
|
||||
handleDrop={handleDrop}
|
||||
handleDrop={async (files)=>{
|
||||
await handleDrop(files)
|
||||
}}
|
||||
>
|
||||
<Breadcrum path={path} onDirClick={(newPath)=>{
|
||||
setPath(newPath)
|
||||
|
||||
Reference in New Issue
Block a user