Fix linkfile prefix
This commit is contained in:
parent
c6260b9d12
commit
92107e1b8f
|
@ -1,5 +1,6 @@
|
||||||
/** @jsx jsx */
|
/** @jsx jsx */
|
||||||
import { AppBar, Button, Card, CardContent, Container, Input, Tab, Tabs, Typography } from "@material-ui/core"
|
import { AppBar, Button, Card, CardContent, Container, Input, Tab, Tabs, Typography } from "@material-ui/core"
|
||||||
|
import * as R from "ramda"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { Box, Flex, jsx } from "theme-ui"
|
import { Box, Flex, jsx } from "theme-ui"
|
||||||
import Dropzone from "../src/components/Dropzone"
|
import Dropzone from "../src/components/Dropzone"
|
||||||
|
@ -14,8 +15,10 @@ const Index = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const directView = () => {
|
const directView = () => {
|
||||||
|
const removeHead = R.compose(R.tail, R.split("sia://"))
|
||||||
|
const hash = removeHead(linkfileUrl)[0]
|
||||||
if (window) {
|
if (window) {
|
||||||
var win = window.open(`/direct/${linkfileUrl}`, "_blank")
|
var win = window.open(`/direct/${hash}`, "_blank")
|
||||||
win.focus()
|
win.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +76,7 @@ const Index = () => {
|
||||||
<p>Download a file by pasting in a Sia linkfile below:</p>
|
<p>Download a file by pasting in a Sia linkfile below:</p>
|
||||||
<Box sx={{ width: "60%" }}>
|
<Box sx={{ width: "60%" }}>
|
||||||
<Input
|
<Input
|
||||||
// placeholder="sia://"
|
placeholder="sia://"
|
||||||
value={linkfileUrl}
|
value={linkfileUrl}
|
||||||
onChange={e => setInput(e.target.value)}
|
onChange={e => setInput(e.target.value)}
|
||||||
sx={{ width: "100%" }}
|
sx={{ width: "100%" }}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
/** @jsx jsx */
|
/** @jsx jsx */
|
||||||
|
import { CircularProgress } from "@material-ui/core"
|
||||||
import * as R from "ramda"
|
import * as R from "ramda"
|
||||||
import { useCallback, useState, useRef } from "react"
|
import { useCallback, useState } 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"
|
||||||
import { CircularProgress, Button } from "@material-ui/core"
|
|
||||||
import { saveAs } from "file-saver"
|
|
||||||
/**
|
/**
|
||||||
* nginx is setup to automatically handle and rewrite the url path.
|
* nginx is setup to automatically handle and rewrite the url path.
|
||||||
*/
|
*/
|
||||||
|
@ -38,7 +37,7 @@ function MyDropzone() {
|
||||||
})
|
})
|
||||||
.then(({ sialink }) => {
|
.then(({ sialink }) => {
|
||||||
console.log("WE OUT HERE BOYS", sialink)
|
console.log("WE OUT HERE BOYS", sialink)
|
||||||
setLink(sialink)
|
setLink(`sia://${sialink}`)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
@ -61,21 +60,21 @@ function MyDropzone() {
|
||||||
<h5>{link}</h5>
|
<h5>{link}</h5>
|
||||||
</Flex>
|
</Flex>
|
||||||
) : (
|
) : (
|
||||||
<Flex
|
<Flex
|
||||||
{...getRootProps()}
|
{...getRootProps()}
|
||||||
sx={{ height: 400, justifyContent: "center", alignItems: "center" }}
|
sx={{ height: 400, justifyContent: "center", alignItems: "center" }}
|
||||||
>
|
>
|
||||||
<input {...getInputProps()} />
|
<input {...getInputProps()} />
|
||||||
{isDragActive && !loading && !error && !link && (
|
{isDragActive && !loading && !error && !link && (
|
||||||
<p>Drop file here ...</p>
|
<p>Drop file here ...</p>
|
||||||
)}
|
)}
|
||||||
{!isDragActive && !loading && !error && !link && (
|
{!isDragActive && !loading && !error && !link && (
|
||||||
<p>Drag 'n' drop a file here, or click to select a file</p>
|
<p>Drag 'n' drop a file here, or click to select a file</p>
|
||||||
)}
|
)}
|
||||||
{loading && <CircularProgress />}
|
{loading && <CircularProgress />}
|
||||||
{error && !loading && <h5>{error}</h5>}
|
{error && !loading && <h5>{error}</h5>}
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue