diff --git a/packages/siaviewnode-client/src/components/TabPanel.tsx b/packages/siaviewnode-client/src/components/TabPanel.tsx
new file mode 100644
index 00000000..d2bf5faa
--- /dev/null
+++ b/packages/siaviewnode-client/src/components/TabPanel.tsx
@@ -0,0 +1,6 @@
+/** @jsx jsx */
+import { Box, jsx } from "theme-ui"
+
+export const TabPanel = ({ children, value, index, ...props }) => {
+ return {value === index && {children}}
+}
diff --git a/packages/siaviewnode-server/package.json b/packages/siaviewnode-server/package.json
index 6cf75978..c1cf997d 100644
--- a/packages/siaviewnode-server/package.json
+++ b/packages/siaviewnode-server/package.json
@@ -17,6 +17,7 @@
"express-fileupload": "1.1.6",
"express-session": "1.17.0",
"ramda": "0.26.1",
+ "shortid": "2.2.15",
"typescript": "^3.5.2"
},
"devDependencies": {
diff --git a/packages/siaviewnode-server/src/main.ts b/packages/siaviewnode-server/src/main.ts
index 1ab2b18d..5c292b89 100644
--- a/packages/siaviewnode-server/src/main.ts
+++ b/packages/siaviewnode-server/src/main.ts
@@ -1,4 +1,5 @@
import * as express from "express"
+import * as shortid from "shortid"
import * as fileUpload from "express-fileupload"
import * as R from "ramda"
import * as cors from "cors"
@@ -19,6 +20,10 @@ const siad = axios.create({
}
})
+// Ramda shared utility functions
+const selectFile = R.path(["files", "file"])
+const pName = R.prop("name")
+
declare var __DEV__: boolean
export class Server {
@@ -63,14 +68,45 @@ export class Server {
limits: { fileSize: 10 * 1024 * 1024 }
})
)
+ // siafile
this.app.post("/siafile", this.postSiaFile)
+ // linkfile
+ this.app.post("/linkfile", this.handleLinkUpload)
+ }
+
+ private async handleLinkUpload(
+ req: express.Request,
+ res: express.Response
+ ): Promise {
+ const fileToUpload: any = selectFile(req)
+ console.log("file:", fileToUpload)
+ const filename = pName(fileToUpload)
+ console.log("filename:", filename)
+ const uid = shortid.generate()
+ console.log("uid:", uid)
+ try {
+ // TODO: add uuid so we don't collide
+ const { data } = await siad.post(
+ `/renter/linkfile/linkfiles/${uid}`,
+ fileToUpload.data,
+ {
+ params: {
+ name: filename
+ }
+ }
+ )
+ console.log("data is ", data)
+ return res.send(data)
+ } catch (err) {
+ console.log("err", err)
+ return res.sendStatus(500)
+ }
}
private async postSiaFile(
req: express.Request & any,
res: express.Response
): Promise {
- const selectFile = R.path(["files", "file"])
try {
const file: any = selectFile(req)
@@ -89,7 +125,6 @@ export class Server {
)
const contentLength = headers["Content-Length"]
- const pName = R.prop("name")
const splitFilename = R.compose(R.head, R.split(".sia"))
const fileName = R.compose(splitFilename, pName)(file)
diff --git a/yarn.lock b/yarn.lock
index 3f006b64..48da2a72 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6451,6 +6451,11 @@ nan@^2.12.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
+nanoid@^2.1.0:
+ version "2.1.8"
+ resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.8.tgz#2dbb0224231b246e3b4c819de7bfea6384dabf08"
+ integrity sha512-g1z+n5s26w0TGKh7gjn7HCqurNKMZWzH08elXzh/gM/csQHd/UqDV6uxMghQYg9IvqRPm1QpeMk50YMofHvEjQ==
+
nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -8543,6 +8548,13 @@ shell-quote@^1.6.1:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==
+shortid@2.2.15:
+ version "2.2.15"
+ resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122"
+ integrity sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==
+ dependencies:
+ nanoid "^2.1.0"
+
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"