add filename
This commit is contained in:
parent
6d5b7bacdd
commit
a575a5c4d3
|
@ -4,12 +4,15 @@ import { useCallback } from "react"
|
||||||
import { useDropzone } from "react-dropzone"
|
import { useDropzone } from "react-dropzone"
|
||||||
import { Box, Flex, jsx } from "theme-ui"
|
import { Box, Flex, jsx } from "theme-ui"
|
||||||
|
|
||||||
const API_ENDPOINT = "/api"
|
const API_ENDPOINT = "http://144.76.136.122/api"
|
||||||
|
|
||||||
|
const pName = R.prop("name")
|
||||||
|
|
||||||
function MyDropzone() {
|
function MyDropzone() {
|
||||||
const onDrop = useCallback(acceptedFiles => {
|
const onDrop = useCallback(acceptedFiles => {
|
||||||
const file = R.head(acceptedFiles)
|
const file = R.head(acceptedFiles)
|
||||||
const fd = new FormData()
|
const fd = new FormData()
|
||||||
|
const fileName = pName(file as any)
|
||||||
fd.append("file", file)
|
fd.append("file", file)
|
||||||
if (window) {
|
if (window) {
|
||||||
const streamSaver = require("streamsaver")
|
const streamSaver = require("streamsaver")
|
||||||
|
@ -22,7 +25,7 @@ function MyDropzone() {
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const readableStream = res.body
|
const readableStream = res.body
|
||||||
const fileStream = streamSaver.createWriteStream("file.webm")
|
const fileStream = streamSaver.createWriteStream(fileName)
|
||||||
|
|
||||||
// more optimized
|
// more optimized
|
||||||
if (window.WritableStream && readableStream.pipeTo) {
|
if (window.WritableStream && readableStream.pipeTo) {
|
||||||
|
|
Reference in New Issue