aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/DownloadManager.ts
diff options
context:
space:
mode:
authorkimdahey <claire_kim1@brown.edu>2020-01-16 11:31:41 -0500
committerkimdahey <claire_kim1@brown.edu>2020-01-16 11:31:41 -0500
commit6be0e19ed0bd13f3796f542affa5a2e52674650c (patch)
tree1be222ea9341ecd8020fad3149035fa650a8a07f /src/server/ApiManagers/DownloadManager.ts
parent5cde81d8c6b4dcd8d0796f8669b668763957f395 (diff)
parente410cde0e430553002d4e1a2f64364b57b65fdbc (diff)
merged w master
Diffstat (limited to 'src/server/ApiManagers/DownloadManager.ts')
-rw-r--r--src/server/ApiManagers/DownloadManager.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/server/ApiManagers/DownloadManager.ts b/src/server/ApiManagers/DownloadManager.ts
index 2280739fc..1bb84f374 100644
--- a/src/server/ApiManagers/DownloadManager.ts
+++ b/src/server/ApiManagers/DownloadManager.ts
@@ -7,6 +7,7 @@ import { Database } from "../database";
import * as path from "path";
import { DashUploadUtils, SizeSuffix } from "../DashUploadUtils";
import { publicDirectory } from "..";
+import { serverPathToFile, Directory } from "./UploadManager";
export type Hierarchy = { [id: string]: string | Hierarchy };
export type ZipMutator = (file: Archiver.Archiver) => void | Promise<void>;
@@ -32,7 +33,7 @@ export default class DownloadManager extends ApiManager {
register({
method: Method.GET,
subscription: new RouteSubscriber("imageHierarchyExport").add('docId'),
- onValidation: async ({ req, res }) => {
+ secureHandler: async ({ req, res }) => {
const id = req.params.docId;
const hierarchy: Hierarchy = {};
await buildHierarchyRecursive(id, hierarchy);
@@ -43,7 +44,7 @@ export default class DownloadManager extends ApiManager {
register({
method: Method.GET,
subscription: new RouteSubscriber("downloadId").add("docId"),
- onValidation: async ({ req, res }) => {
+ secureHandler: async ({ req, res }) => {
return BuildAndDispatchZip(res, async zip => {
const { id, docs, files } = await getDocs(req.params.docId);
const docString = JSON.stringify({ id, docs });
@@ -58,7 +59,7 @@ export default class DownloadManager extends ApiManager {
register({
method: Method.GET,
subscription: new RouteSubscriber("serializeDoc").add("docId"),
- onValidation: async ({ req, res }) => {
+ secureHandler: async ({ req, res }) => {
const { docs, files } = await getDocs(req.params.docId);
res.send({ docs, files: Array.from(files) });
}
@@ -245,9 +246,9 @@ async function writeHierarchyRecursive(file: Archiver.Archiver, hierarchy: Hiera
if (typeof result === "string") {
let path: string;
let matches: RegExpExecArray | null;
- if ((matches = /\:1050\/files\/(upload\_[\da-z]{32}.*)/g.exec(result)) !== null) {
+ if ((matches = /\:1050\/files\/images\/(upload\_[\da-z]{32}.*)/g.exec(result)) !== null) {
// image already exists on our server
- path = `${__dirname}/public/files/${matches[1]}`;
+ path = serverPathToFile(Directory.images, matches[1]);
} else {
// the image doesn't already exist on our server (may have been dragged
// and dropped in the browser and thus hosted remotely) so we upload it