Implemented multi-file upload/download
This commit is contained in:
parent
b2aed06328
commit
7bf104960e
18 changed files with 475 additions and 183 deletions
33
app/archive.js
Normal file
33
app/archive.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { blobStream, concatStream } from './streams';
|
||||
|
||||
export default class Archive {
|
||||
constructor(files) {
|
||||
this.files = Array.from(files);
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.files.length > 1 ? 'Send-Archive.zip' : this.files[0].name;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return this.files.length > 1 ? 'send-archive' : this.files[0].type;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.files.reduce((total, file) => total + file.size, 0);
|
||||
}
|
||||
|
||||
get manifest() {
|
||||
return {
|
||||
files: this.files.map(file => ({
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
type: file.type
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
get stream() {
|
||||
return concatStream(this.files.map(file => blobStream(file)));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue