Scenario:
1) I'm inside Dropbox Cloud.
2) I have a few files there.
3) I click "Download" for a specific file.
4) The file is immediately downloaded in the browser.
Let's review section 4)
I would like to hijack the download request so I can manipulate it to "download" \ "send the file" to a local server of mine rather than directly downloading the file.
I can think of a few ways to do that:
1) A small chrome extension that runs in the background and query the DOM in order to assemble the download link and then send it to my server so I can send a get request to it.
2) Parsing the html page with a small web scraper and do the exact thing I would do as section 1)
3) Use Dropbox API V2 in order to get a url link for a specific file or a specific container with its links and then initiate a download request whenever I choose to.
Yet, I would like to know if there is a way to directly takeover the initiated download request on the browser, so I can route it to another server of mine.
I'm asking this because eventually I would like to transform the file on my side and only then to once again initiate the download request (via a hidden form with a listener let's say) to the one who initiated the download
A flow image to be more clear:
Related
Soppose I develop a client web app (I don't have access to server code), Is it possible to detect when user downloads a file? I need something like:
//fires when user download file
function downloadFileCreated(obj){
alert(obj.url); // prints the download link
}
here they assume that I have access to server code (but I don't have)
(I'm working on InternetExplorer add-on and I want to inject script that listening to user download)
How about using Google analytics like mentioned in below post?
Best way to count number of downloads of several files on website
Our application implements a custom download manager.
So actually this means that when a user starts a download of a resource he/she has the opportunity to cancel it through a UI button from the app, which actually sends some event to the server to cancel the downloading (the connection is disconnected and etc).
But since recently Chrome added auto-resume of failed downloads, so the same request is resumed to be downloaded again from the Chrome Download Manager, it's because Chrome cannot distinguish that the user/server intentionally canceled the HTTP connection so it revokes it again.
Currently, we download resources using IFrame, but once the download is started by the browser changing the IFrame's src attribute is not relevant anymore. I've tried to use <a href='...' download> but the issue is the same.
Maybe there's some API at least for Chrome? (There's actually such for Chrome extensions but this is not the case)
You cannot control the downloads that are managed by the download manager, of the browser.
If you want to control the download then you need to fetch the file JavaScript by e.g. utilizing the Streams API.
After you downloaded the Data you can pass that file to the download manager of the browser.
Each of those tasks can be solved in different ways.
Could you do something like add a unique key to the URL for each download request? When the user cancels the download, you invalidate the key so that the URL cannot be used again to download that resource - and in the process prevents Chrome from being able to resume the download.
I have this problem. I have a website which has URLs to videos from different website (not in my servers). What I exactly want when the user clicks on any of these link the video in remote website is downloaded. But what I have now when the user clicks on the link the video is open and show on the browser instead of download. I created a source code in ASP.net and C# that could force the browser to download the video, but the problem here is that my server should process the downloading operation to the browser, in other word that data should pass through my server to the client browser rather than from the third website to the client directly.
This will have two problems
it waste my server resources and effectiveness because the data should be processed through the server
it will increase the In and out bandwidth for my server and all the files are videos so it will be very costly.
What I want now, is there a way that enables me to force the browser to download the file directly from third party and without passing data through my server by using JavaScript, jQuery, or any client side techniques?
The html5 download attribute could help here. I haven't tested it personally but this blogpost says adding download should force a download on the browser side.
Example code:
Download
I have the following external pdf embedded as shown below. The pdf displays fine, but how do I cache the pdf so that the page doesn't redownload the pdf each time I visit the page? Should I use an object tag instead?
<embed src="http://samplepdf.com/sample.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="375">
From my understanding, you have a pdf on your server that you would like to cache onto the client side so that the pdf is not redownloaded each time the user refreshes the page.
By sending the proper headers, you can enforce cache rules (or at least try to enforce them as any browser can overrule your rules).
Php or in your case, Django, can send the appropriate headers to tell the browser to cache this pdf. My recommendation would be that you link that you provide in the embed tag links to a script instead of the pdf diriectly. This django script would sent out 2 sets of headers. One tells the browser to cache this content and other tells the browser it is sending a PDF file. This ensures that the pdf gets cached. When you load a webpage, the typical headers' scope by not encompass all external files/pdfs. As each is a separate request.
The method that I prescribed adds extra work than simply embedding the pdf but it should get the job done.
Can anyone guide me to implement a javascript function, which takes as Argument "file content" (read from web service as httpresponse body), and show a file save or file open dialog in browser?
Direct link to file is not available, all I can read is file content via web service. Can anybody guide me here?
I think you would have to use JavaScript to redirect to some PHP (Or any other server side scripting language) file that sends the correct headers. It would stay on the page as long as you get the headers right, here is an example.
So after setting up your server side script to serve the file. You will need to redirect the user to that file like so.
window.location = 'http://myserver.co.uk/download.php';