Commit baf16615 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Handled upload errors

parent 3d0c8655
Loading
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -188,15 +188,23 @@ export default new Vuex.Store({
      for (let file of files) {
        names.push(file.name);
      }
      client.prepareForUpload(state.path, names)
      return client.prepareForUpload(state.path, names)
        .then(uploadUrls => {
          let uploads = [];
          for (let i = 0; i < files.length; i++) {
            uploads.push(client.uploadFile(uploadUrls[i], files[i]));
          }
          Promise.all(uploads).then(() => {
          Promise.all(uploads)
            .then(() => {
              // Reload current node when all uploads completed
              dispatch('setPath', state.path);
            })
            .catch(error => {
              let message = "Unable to upload file"
              if (error.response && error.response.data) {
                message += ": " + error.response.data;
              }
              main.showError(message);
            });
        });
    },