aboutsummaryrefslogtreecommitdiff
path: root/src/client/Network.ts
diff options
context:
space:
mode:
authormonoguitari <113245090+monoguitari@users.noreply.github.com>2023-08-22 14:15:04 -0400
committermonoguitari <113245090+monoguitari@users.noreply.github.com>2023-08-22 14:15:04 -0400
commit9293fd8c4128b41b31f9b2214d6799fdff0f2aaa (patch)
tree45809c42545b10515f6f88065318b454549dacd1 /src/client/Network.ts
parent347e8e2bd32854b36828b7bcc645c9c361204251 (diff)
parent1c52bd054385d2584bbeae41eecdf9ba6999c25f (diff)
Merge branch 'master' into advanced-trails
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r--src/client/Network.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts
index d606b9854..39bf69e32 100644
--- a/src/client/Network.ts
+++ b/src/client/Network.ts
@@ -5,7 +5,7 @@ import { Upload } from '../server/SharedMediaTypes';
/**
* Networking is repsonsible for connecting the client to the server. Networking
* mainly provides methods that the client can use to begin the process of
- * interacting with the server, such as fetching or uploading files.
+ * interacting with the server, such as fetching or uploading files.
*/
export namespace Networking {
export async function FetchFromServer(relativeRoute: string) {
@@ -25,9 +25,9 @@ export namespace Networking {
/**
* FileGuidPair attaches a guid to a file that is being uploaded,
* allowing the client to track the upload progress.
- *
+ *
* When files are dragged to the canvas, the overWriteDoc's ID is
- * used as the guid. Otherwise, a new guid is generated.
+ * used as the guid. Otherwise, a new guid is generated.
*/
export interface FileGuidPair {
file: File;
@@ -38,9 +38,10 @@ export namespace Networking {
* with the mapping of guid to files as parameters.
*
* @param fileguidpairs the files and corresponding guids to be uploaded to the server
+ * @param browndash whether the endpoint should be invoked on the browndash server
* @returns the response as a json from the server
*/
- export async function UploadFilesToServer<T extends Upload.FileInformation = Upload.FileInformation>(fileguidpairs: FileGuidPair | FileGuidPair[]): Promise<Upload.FileResponse<T>[]> {
+ export async function UploadFilesToServer<T extends Upload.FileInformation = Upload.FileInformation>(fileguidpairs: FileGuidPair | FileGuidPair[], browndash?: boolean): Promise<Upload.FileResponse<T>[]> {
const formData = new FormData();
if (Array.isArray(fileguidpairs)) {
if (!fileguidpairs.length) {
@@ -57,17 +58,19 @@ export namespace Networking {
])
);
}
- // If the fileguidpair has a guid to use (From the overwriteDoc) use that guid. Otherwise, generate a new guid.
+ // If the fileguidpair has a guid to use (From the overwriteDoc) use that guid. Otherwise, generate a new guid.
fileguidpairs.forEach(fileguidpair => formData.append(fileguidpair.guid ?? Utils.GenerateGuid(), fileguidpair.file));
} else {
- // Handle the case where fileguidpairs is a single file.
+ // Handle the case where fileguidpairs is a single file.
formData.append(fileguidpairs.guid ?? Utils.GenerateGuid(), fileguidpairs.file);
}
const parameters = {
method: 'POST',
body: formData,
};
- const response = await fetch('/uploadFormData', parameters);
+
+ const endpoint = browndash ? '[insert endpoint allowing local => browndash]' : '/uploadFormData';
+ const response = await fetch(endpoint, parameters);
return response.json();
}