From a575a5c4d3aa6895de4c61fbb31af3f912075746 Mon Sep 17 00:00:00 2001 From: Eddie Wang Date: Tue, 3 Dec 2019 16:42:47 -0500 Subject: [PATCH] add filename --- packages/siaviewnode-client/src/components/Dropzone.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/siaviewnode-client/src/components/Dropzone.tsx b/packages/siaviewnode-client/src/components/Dropzone.tsx index 82b045a9..00bec0d9 100644 --- a/packages/siaviewnode-client/src/components/Dropzone.tsx +++ b/packages/siaviewnode-client/src/components/Dropzone.tsx @@ -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) {