async uploadButtonClicked()

in frontend/app/DeliverableUploader/UploaderMain.tsx [84:137]


  async uploadButtonClicked() {
    this.setState({ uploadInProgress: true }, async () => {
      try {
        const projectIdInt = parseInt(this.props.projectId);
        const uploadId = await InitiateUpload(
          projectIdInt,
          this.props.dropFolder
        );
        console.debug("upload id is ", uploadId);
        for (let i = 0; i < this.state.files.length; ++i) {
          const didValidate = await UploadAndValidate(
            this.state.files[i],
            i,
            uploadId,
            5242880, //5Mb chunk size
            (updatedEntry, index) => {
              this.setState((prevState) => {
                let updatedFileState: FileEntry[] = Object.assign(
                  [],
                  prevState.files
                );
                updatedFileState[index] = updatedEntry;
                return { files: updatedFileState };
              });
            }
          );

          this.setState((prevState) => {
            let updatedFileState: FileEntry[] = Object.assign(
              [],
              prevState.files
            );
            const updatedEntry = Object.assign({}, this.state.files[i]);
            updatedEntry.lastError = didValidate
              ? "Completed OK"
              : "Upload was corrupted";
            updatedFileState[i] = updatedEntry;
            return { files: updatedFileState };
          });

          console.log(
            `Upload for ${i + 1} / ${
              this.state.files.length
            } completed or failed`
          );
        }
        this.setState({ uploadInProgress: false });
        console.log("All done!");
      } catch (err) {
        console.error(err);
        this.setState({ uploadInProgress: false });
      }
    });
  }