aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2020-02-12 16:32:48 -0500
committerSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2020-02-12 16:32:48 -0500
commit736dde96336c5a00d3761f0894157b51a26081cc (patch)
treef2420133a422cd5e3e6bb8ef8f7d054f8a4b7c31
parent2d76d891cb6a656f3c404d17ffa1cac05e08d115 (diff)
standardized upload file response, particularly as it applies to video
-rw-r--r--src/client/views/collections/CollectionSubView.tsx4
-rw-r--r--src/server/DashUploadUtils.ts10
2 files changed, 8 insertions, 6 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index acab45078..32480ad4e 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -315,9 +315,9 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
const dropFileName = file ? file.name : "-empty-";
promises.push(Networking.PostFormDataToServer("/uploadFormData", formData).then(results => {
results.map(action((result: any) => {
- const { agnostic, accessPaths, nativeWidth, nativeHeight, contentSize } = result;
+ const { accessPaths, nativeWidth, nativeHeight, contentSize } = result;
const full = { ...options, _width: 300, title: dropFileName };
- const pathname = Utils.prepend(accessPaths?.agnostic.client || agnostic.client);
+ const pathname = Utils.prepend(accessPaths.agnostic.client);
Docs.Get.DocumentFromType(type, pathname, full).then(doc => {
if (doc) {
const proto = Doc.GetProto(doc);
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 0f1758c26..9ccc860f1 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -97,7 +97,7 @@ export namespace DashUploadUtils {
}
console.log(red(`Ignoring unsupported file (${name}) with upload type (${type}).`));
- return { accessPaths: undefined };
+ return { accessPaths: {} };
}
async function UploadPdf(absolutePath: string) {
@@ -216,13 +216,15 @@ export namespace DashUploadUtils {
};
};
- export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise<Opt<AccessPathInfo>> {
- return new Promise<Opt<AccessPathInfo>>(resolve => {
+ export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise<Opt<{ accessPaths: AccessPathInfo }>> {
+ return new Promise(resolve => {
const filename = basename(absolutePath);
const destinationPath = serverPathToFile(destination, filename);
rename(absolutePath, destinationPath, error => {
resolve(error ? undefined : {
- agnostic: getAccessPaths(destination, filename)
+ accessPaths: {
+ agnostic: getAccessPaths(destination, filename)
+ }
});
});
});