})
upload = (url: string, path: string, files: File[], config: WebDAVRequestConfig = {}) => {
- const fd = new FormData();
- fd.append('path', path);
- files.forEach((f, idx) => {
- fd.append(`file-${idx}`, f);
- });
-
- return this.request({
+ return files.map(file => this.request({
...config, url,
method: 'PUT',
- data: fd
- });
+ data: file
+ }));
}
copy = (url: string, destination: string, config: WebDAVRequestConfig = {}) =>
return new Promise<XMLHttpRequest>((resolve, reject) => {
const r = this.createRequest();
r.open(config.method, this.defaults.baseURL + config.url);
-
const headers = { ...this.defaults.headers, ...config.headers };
Object
.keys(headers)
headers?: { [key: string]: string };
data?: any;
onUploadProgress?: (event: ProgressEvent) => void;
-}
+}
\ No newline at end of file
import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions';
import { reset, startSubmit, stopSubmit } from 'redux-form';
import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { collectionPanelFilesAction } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
+import { createTree } from '~/models/tree';
+import { loadCollectionPanel } from '../collection-panel/collection-panel-action';
export const uploadCollectionFiles = (collectionUuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
try {
dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPLOAD_FILES_DIALOG));
dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG));
- await dispatch<any>(uploadCollectionFiles(currentCollection.uuid));
+ await dispatch<any>(uploadCollectionFiles(currentCollection.uuid))
+ .then(() => dispatch<any>(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() })));
dispatch<any>(loadCollectionFiles(currentCollection.uuid));
+ dispatch<any>(loadCollectionPanel(currentCollection.uuid));
dispatch(closeUploadCollectionFilesDialog());
dispatch(snackbarActions.OPEN_SNACKBAR({
message: 'Data has been uploaded.',
const handleUploadProgress = (dispatch: Dispatch) => (fileId: number, loaded: number, total: number, currentTime: number) => {
dispatch(fileUploaderActions.SET_UPLOAD_PROGRESS({ fileId, loaded, total, currentTime }));
-};
+};
\ No newline at end of file