How can i show progress & speed of download [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
First, thanks to help me!
How can i make a file first download to the browser and after that just popup the file... e.g http://mega.nz
I did server side script php, it sends to browser the file in chunks with the content-disposition header and it works!
But i want first download it to browser and show progress & speed.
English isn't my main language...

This is not going to be a complete answer, but I will try and get you started on the right path.
First off, you'll need to use the a filesystem API to download your file to the browser cache. For chrome you can find more info here: https://developer.chrome.com/apps/fileSystem
The API extends through HTML5 though, so you can do this in other browsers as well. See this article for more information: http://www.html5rocks.com/en/tutorials/offline/quota-research/#toc-desktop
Now that is how it works behind the scenes, as far as implementing it yourself, take a look at FileSaver.js
From their Github:
FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it. There is a FileSaver.js demo that demonstrates saving various media types.
FileSaver.js is the solution to saving files on the client-side, and is perfect for webapps that need to generate files, or for saving sensitive information that shouldn't be sent to an external server.
This should allow you to target any modern browser for large file downloading, as well as pausing and resuming downloads.
You may also want to look into NodeJS as there will likely be some packages made already you could leverage in your server application.

The way Mega.nz works is by using the FileSystem API. It writes the file in a "cached" form on your system in an example location as such:
AppData\Local\Google\Chrome\User Data\Default\File System\
What are the benefits of this? Visually none, other than it just makes the feel of downloading something different.
How do you do this? It's not an easy, type this code and you're done! They have clouds set up for this. I would first research FileSystem.

Related

Is it faster to upload one big file or more smaller ones? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
first of all I don't know if question like this already exists, I tried but couldn't find it, so if there is I apologize.
I am trying to stream video by sending each frame to client and then displaying it using Javascript on Website. (so it all works using WebSockets).
I host websocket server on a PC (c# is the language). So, I take screenshot of entire screen and immediately send it over to client.
Now, my question is: should I store multiple frames (say 3?) to one file, then upload that file or should I send frame by frame like I already do? I wonder which one is faster?
Thank you.
They are both going to upload the same size of file, one will be split up though so. They should theoretically upload at the same time- this all depends on bandwith also.
I believe that either way they will be split into packets when they cross networks, so it is more about how you would like to deal with the frames on the client side. If I were you I would let the lower technologies handle details like this (e.g the frameworks or libraries you are using) unless you have a specific purpose for sending the frames in intervals because it will add time on to the upload and it adds more room for things to go wrong with separate loads of frames. E.g; you could send the split frames in the wrong order.

How to download a file from a url in Node JS? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What's the best way to download a file from a given url? There are times when the url is not the actual url of the file but a "follow to" url which takes us to a file or sometimes a video player is present on the link that plays the video.
How can we ensure the download of the file from those links? Is there any solution to this?
Probably what you want is the request library or it's promise-based version the request-promise library.
The request library will follow 3xx redirects by default, assuming that's what you meant by "follow to" url.
If the link takes you to a web page that contains a video player, what the request library in node.js will download is the web page, not all the other resources referenced in the web page. If you want to download a specific resource used in the web page, then you have to download the web page, parse it with a tool such as cheerio, find the link to the resource you actually want in that web page and then download that specific resource using its URL.
As always with questions here on stack overflow, the more you explain about the eventual final result you're trying to achieve, the better we can help you here. Based on what you've disclosed in the question so far, I think I've answered what you asked, but it feels like there's probably more to the real question than what you've shown so far.

What are some advantages and disadvantages for embedding JavaScript in HTML or saving it externally? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm looking for simple bullet point answers please. I've tried looking all over, Googling, other questions here but I can never find both advantages and disadvantages for each method.
This is the answer I got from W3Schools pertaining to external javascript files
Pros
It allows separation of concerns - which is not a big deal in simple pages but as the script grows larger you can have a monolithic html page. Big files in general are not ideal for maintainability
It allows caching - when the browser loads a script externally (whether it's be from your site or a cdn) it caches the file for future use. That's why cdn's are preferred for commonly used scripts. Makes the browser use a cached script instead of building a new one every time the page loads which makes the page load faster
More readable code - this ties into the first bullet point but nevertheless it is important. The smaller the files we humans are working with the better. It is easier to catch mistakes and much easier to pass of the torch to the next developer working on the project or learning from it.
Cons
The browser has to make an http request to get the code
There may be other browser specific reasons as well, but I believe the main reason is the separation of code into different components.
Probably the best advantage of using external javascript files is browser caching - which gives you a good performance boost.
Imagine you have a site that uses MyJsFile.js (a random 50kb javascript file that adds functionality to your websire).
You can:
embed it in every page, and add the 50kb to every page request (not ideal)
link it in every page (<script src="MyJsFile.js"></script>)
The second option is usually prefered because most modern browsers will only get the file once, and serve it from the browser cache instead of downloading it at every request.
Check out similar questions:
Why not embed styles/scripts in HTML instead of linking?
When should I use Inline vs. External Javascript?
Is it better to put the JS code on the html file or in an external file?

Fastest way to upload big files [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've implemented fineuploader to upload a file without reloading the page. Problem is it is very slow and potentially fails for vary large files (~300M). Note that I am only using Fineuploader 3.1, but expect it will not make a difference to use a more current version.
My question is whether I shouldn't use some sort of Ajax based file upload approach at all for large files, but based on their size fall back to some more traditional solution which reloads the page? What would be the fastest way to upload a big file using a website and not FTP, etc?
You could have a look at:
Resumable.js Fault Tolerant Resumable File Uploads in JavaScript
As far as I think large files are prone to fault so it is a good idea to make it ressumable.
Fine Uploader has changed a lot since 3.1. The current version is already 4.4. You likely will notice a big difference if you upgrade. Also, Fine Uploader is not causing you failures, your network connection is the culprit.
Fine Uploader 5.0 is set to be released next week, and it includes one big feature that will help you specifically as this feature is aimed as speeding up single file large uploads: concurrent chunking. No other upload library offers this feature (it was very complicated to implement). The concurrent chunking feature has been shown to speed up single file large uploads by a factor of at least 2. It does this by sending as many chunks as possible at the same time for a single file. You can read more about this feature in the pre release notes at http://docs.fineuploader.com/branch/develop/features/concurrent-chunking.html.
Note that Fine Uploader also offers the same features as resumable.js along with many other features such as auto retry, image scaling, form support, direct uploads to S3 and Azure, and more.

Firefox plugin that can modify incoming data before the page processes it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
Say a webpage loads an external javascript at load, is there any such FireFox plugin that I could use to modify the javascript before the page actually processes it?
(not just specifically javascript)
Thanks in advance.
(also I'm pretty sure Tamper Data plugin only changes header data and not actual content being received)
For everyone that has never used tamperdata: Tamper data is for OUTGOING requests. Tamper Data can modify the ENTIRE request, except the URL which requires you to replay the request.
Using GreaseMonkey you can make stand-alone custom plugins that can modify any element of the page before it loads.
Here is THE GUIDE you want which explains GreaseMonkey.
Here are a massive number of GreaseMonkey "UserScripts". This site contains many examples of what you are looking for.
You have a couple options:
Tamper Data will modify POST parameters (and GET really since you can modify the URL).
You can also combine FoxyProxy (https://addons.mozilla.org/en-US/firefox/addon/2464) with any number of free interactive proxies (Fiddler, Paros, Burp, Charles)
Finally you can choose to not use a proxy and write up a greasemonkey script.
I think you'll likely have the most luck with the FoxyProxy + proxy approach. Unfortunately it's not a single addon.
The minimalistic browser-agnostic approach would be to write your own bookmarklet. For example I have found the Show Hiddens bookmarklet to be extremely useful for debugging form submissions. While extremely simple the bookmarklet does things which Tamper Data cannot.
I have found it here:
http://www.squarefree.com/bookmarklets/forms.html
Also the Forms tab in the Web Developer toolbar has some useful options.
If You want to change a downloadable resource, use Opera, set it's cache to never expire, and modify the files cached. That's how I did it a year or two ago, successfully.
I believe GreaseMonkey can modify the data in the page, though I'm not sure if it's executed before or after the page loads.
Check out TamperMonkey for Chrome: http://tampermonkey.net/
Or if you want to do it manually, in Chrome, it's really simple.
In Chrome, browse to: chrome://extensions. Then drag your .js file into that page.
Chrome will automatically create a manifest.json file in the Chrome AppData folder.
You can change the manifest.json file to filter the websites you want to use your script on.

Categories