add filename

This commit is contained in:
Eddie Wang 2019-12-03 16:42:47 -05:00
parent 6d5b7bacdd
commit a575a5c4d3
No known key found for this signature in database
GPG Key ID: DBFB3E83121BEDD1
1 changed files with 5 additions and 2 deletions

View File

@ -4,12 +4,15 @@ import { useCallback } from "react"
import { useDropzone } from "react-dropzone"
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() {
const onDrop = useCallback(acceptedFiles => {
const file = R.head(acceptedFiles)
const fd = new FormData()
const fileName = pName(file as any)
fd.append("file", file)
if (window) {
const streamSaver = require("streamsaver")
@ -22,7 +25,7 @@ function MyDropzone() {
}
}).then(res => {
const readableStream = res.body
const fileStream = streamSaver.createWriteStream("file.webm")
const fileStream = streamSaver.createWriteStream(fileName)
// more optimized
if (window.WritableStream && readableStream.pipeTo) {