Comments (7)
FWIW, here is a function I came up with for generating an MD5 hash of a File
object using spark-md5 and chunked-file-reader:
function fileMD5 (file) {
return new Promise(function (resolve, reject) {
var spark = new SparkMD5.ArrayBuffer(),
reader = new ChunkedFileReader();
reader.subscribe('chunk', function (e) {
spark.append(e.chunk);
});
reader.subscribe('end', function (e) {
var rawHash = spark.end(true);
var base64Hash = btoa(rawHash);
resolve(base64Hash);
});
reader.readChunks(file);
})
}
The chunked-file-reader
is probably not going to be necessary, since tus-js-client is splitting the File
object into chunks of Blob
objects which are already loaded whole into memory.
For files of 20MB this takes about 600ms on my machine. I don't expect anyone to use chunks larger than 20MB, so I think it's a pretty small overhead. I haven't compared spark-md5 with other alternatives, but spark-md5 claims to be very fast.
from tus-js-client.
Well, there are different reasons why these extensions haven't been implemented yet:
- The Checksum extension requires that the checksum is calculated inside the browser. While this is totally doable today, it's particularly expensive and time intensive for bigger files and on mobile devices. Of course, we could utilise the new Web Crypto API, which probably offers better performance and security, but you could argue whether it has reached critical mass yet (see http://caniuse.com/#feat=cryptography).
- The Concatenation extension is mostly meant for parallel uploads where you need to utilise multiple HTTP connections. In most cases, this does not apply to the environment of the browser but it can also be used for different things. Supporting this is basically just adding some headers.
- The Termination extension is pretty much the same as with the concatenation. Just adding a new HTTP method and there you go. :)
To summaries, there is no real reason why extension support is not high right now, except the (maybe) missing needs and technical details. A user could build the required code on top of tus-js-client but is not supposed to do so. I hope to improve the situation soon.
from tus-js-client.
@Acconut makes total sense - and please don't take my question as criticism - this protocol definition is exactly what we (the webdev community) needed!
I want to make sure I understand the Concatenation extension - let me explain my use case and see if it fits. I want to give my users the ability to upload medium-to-large video files (in excess of 350MB) over a mobile hotspot. The browser will be on a laptop (not mobile). In order to maximize network performance - I like to make the upload multi-threaded. Essentially - I'd like to upload one file over 3 to 5 HTTP connections. Could concatenation be used for this?
from tus-js-client.
Yes, that's one of the use cases we designed the Concatenation extension for.
from tus-js-client.
@Acconut I like your explanations in #29 (comment), would it make sense to cement (some of) those in README.md
?
from tus-js-client.
@janko-m Those are some promising numbers, thanks for sharing!
from tus-js-client.
Another update, the default chunk size for ChunkedFileReader
is 256 KB, which I think is bit too small. I tried bumping the chunk size to 2MB, which I think is very reasonable, and for me that sped up hashing from 600ms to 200ms (for a 20MB file).
So, I think we should be good regarding the performance of calculating a checksum, though it would probably be good to also test the speed on mobile devices.
from tus-js-client.
Related Issues (20)
- i try testing from ios error like can help me HOT 2
- supabase tus implementation HOT 4
- MIT License HOT 2
- tus-upload large file not working in Ubuntu nginx server HOT 3
- Switch from HTTPS to HTTP Causes Mixed Content Errors HOT 1
- It's not possible to declare onShouldRetry and fallback to the default behaviour HOT 1
- Failed because: Error: tus: unexpected response while uploading chunk, [...] HOT 12
- define a global maximum concurrent request limit HOT 3
- > net::ERR_UPLOAD_FILE_CHANGED
- TypeError: Cannot read properties of undefined (reading 'Upload') HOT 4
- Base64 Encoding of Metadata Assumes Metadata Value is a UTF8 String (Should It?) HOT 6
- RetryDelays: "Type 'null' is not assignable to type 'number[] | undefined'". But null is acceptable. HOT 2
- Replace Karma test runner
- window is undefined when trying to run in worker file on browser HOT 8
- Duplicate calls to `start` cause duplicate uploads
- Can onSuccess return the file address when the upload is successful? HOT 10
- Provide fallback storage when using tus in Web Workers HOT 3
- Either a Bug or i'm doing something wrong HOT 3
- removeFingerprintOnSuccess not working on multiple files HOT 4
- Decrease browser bundle size HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tus-js-client.