aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorJames Hu <51237606+jameshu111@users.noreply.github.com>2023-06-07 12:45:08 -0400
committerJames Hu <51237606+jameshu111@users.noreply.github.com>2023-06-07 12:45:08 -0400
commitb2c0855d6d701bd80666e0693bd193dc69efb4a0 (patch)
tree352aa79428f7f07902241714f0668a9b72c42227 /src/client/documents/Documents.ts
parent27f518632c24f69fff360bef36eb0e5426167b83 (diff)
Comments
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 0030af982..06b48fe96 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1841,10 +1841,22 @@ export namespace DocUtils {
});
}
+ /**
+ * uploadFilesToDocs will take in an array of Files, and creates documents for the
+ * new files.
+ *
+ * @param files an array of files that will be uploaded
+ * @param options options to use while uploading
+ * @returns
+ */
export async function uploadFilesToDocs(files: File[], options: DocumentOptions) {
const generatedDocuments: Doc[] = [];
- const fileNoGuidPairs: Networking.FileGuidPair[] = [];
- files.map(file => fileNoGuidPairs.push({file}));
+
+ // UploadFilesToServer takes an array of FileGuidPairs,
+ // but these files do not have overwriteDocs, so
+ // we do not set guid, allowing the client to generate one.
+ const fileNoGuidPairs: Networking.FileGuidPair[] = files.map(file => ({file}));
+
const upfiles = await Networking.UploadFilesToServer(fileNoGuidPairs);
for (const {
source: { name, type },
@@ -1857,6 +1869,8 @@ export namespace DocUtils {
export function uploadFileToDoc(file: File, options: DocumentOptions, overwriteDoc: Doc) {
const generatedDocuments: Doc[] = [];
+ // Since this file has an overwriteDoc, we can set the client tracking guid
+ // to the overwriteDoc's guid.
Networking.UploadFilesToServer([{file, guid: overwriteDoc[Id]}]).then(upfiles => {
const {
source: { name, type },