Skip to content
Snippets Groups Projects
Commit fb9bcb59 authored by vkovtun's avatar vkovtun
Browse files

BIS-753: Changed file upload to make folder upload possible.

parent b6472f81
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -165,19 +165,27 @@ export default class DataBrowserController extends ComponentController {
)
}
async upload(file, onProgressUpdate) {
let offset = 0
async upload(fileList, onProgressUpdate) {
let totalUploaded = 0
while (offset < file.size) {
const blob = file.slice(offset, offset + CHUNK_SIZE)
const binaryString = await this._fileSliceToBinaryString(blob);
await this._uploadChunk(this.path + '/' + file.name, offset, binaryString)
offset += CHUNK_SIZE
const files = Array.from(fileList);
const totalSize = files.reduce((acc, file) => acc + file.size, 0)
if (onProgressUpdate) {
// Calculate and update progress
const progress = Math.round((offset / file.size) * 100)
onProgressUpdate(Math.min(progress, 100))
for (const file of files) {
let offset = 0
while (offset < file.size) {
const blob = file.slice(offset, offset + CHUNK_SIZE)
const binaryString = await this._fileSliceToBinaryString(blob)
await this._uploadChunk(this.path + '/' + file.name, offset,
binaryString)
offset += blob.size
totalUploaded += blob.size
if (onProgressUpdate) {
// Calculate and update progress
const progress = Math.round((totalUploaded / totalSize) * 100)
onProgressUpdate(Math.min(progress, 100))
}
}
}
......
......@@ -91,7 +91,7 @@ class RightToolbar extends React.Component {
async handleUploadFiles(event) {
try {
this.setState({ loading: true, progress: 0 })
await this.controller.upload(event.target.files[0], this.updateProgress)
await this.controller.upload(event.target.files, this.updateProgress)
} finally {
this.setState({ loading: false })
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment