how to display the "URL" of a zip file as a download button? - meteor

am using aldeed:collection2 package for my collection and one of the element in the documents is the URL of a zip file.
I already fetched the URL "item.file" but I want to provide that URL as a button, once clicked the download will start.
How do i do this?
thanks

If it's a .zip file, you just need to wrap it in an <a> tag:
<a class="btn btn-primary" href="{{item.file}}">Click to Download</a>
Note that I'm using Bootstrap classes to make it look like a button.

Related

Download links in Blazor

I'm programatically creating links to download files of different formats like .csv and .yml.
My code is
<a href="/organs/#organ/#policy/#folder.Name/#file.Name" download>#file.Name</a>
so lets say these links get created:
https://localhost:44372/organs/Heart-Lung/03-15-2020/data/fakedata.yml
https://localhost:44372/organs/Heart-Lung/03-15-2020/data/testdata.csv
the .csv works as it should, I click and it downloads. the .yml however opens a new web page at that link and then says that it can't be found
I'm really not sure what I'm doing wrong, is there a way force it to download or should I be doing this a different way?
I ended up using javascript to do this, based on https://wellsb.com/csharp/aspnet/blazor-jsinterop-save-file/
most of the code is the same, but I changed the link to this to pass in the variable and to keep it as a clickable link that doesn't go anywhere
<a href="javascript:void(0)" #onclick=#(() => DownloadFile(file.FullName))>#file.Name</a>

Download attribute in <a> tag doesn't work when file URL called from sub domain

I have a blog here where I have used an anchor tag (<a>) with the download attribute for an HTML file:
</i>
Screenshot:
Expected: when the user clicks, it should open the dialogue box to download the file.
However, it navigates to the file. AFAIK, it was working earlier. Not sure what happened, or am I missing something? As per this w3schools example, ".html" file is allowed.
Any help would be much appreciated without using JavaScript.
EDIT:
This blog is in a subdomain (http://blog.idevelopweb.site/) and I'm calling the HTML file which is in the root directory (http://www.idevelopweb.site/) so I have used an absolute path.
I may direct you to here.
Your problem is the same origin policy of the download attribute. So either use the same url or relative path.
Download file when clicking on the link (instead of navigating to the file):
<a href="link" download="logo">
Note: The download attribute is not supported in Edge version 12, IE, Safari 10 (and earlier), or Opera version 12 (and earlier)
In your Code
</i>
The href contain link of the webpage instead of the data , image or file which nedded to be downloaded. The webpage cant be downloaded using download attribute of anchor tag.Thus it should be in format:
<a href= "--link of image or file to be downloaded--" download > Download </a>
For example:
<a href="/images/myw3schoolsimage.jpg" download> Download </a>
This download the myw3schoolsimage.jpg image

Remove link to document caching in ASP.NET

I'm trying to append DateTime.Now.Ticks to my link to stop it from caching as I'll be replacing it often. The problem I'm having when I do the code below is that it's adding a Content path in the url.
The original link was:
<a target="_blank" href="~/Documents/Data/Acct/MyDocument.pdf">Document</a>
This obviously caches the file on the browser so when I overwrite MyDocument.pdf the users don't see that unless they Ctrl-F5. So I changed it to the following:
<a target="_blank" href=#string.Format("{0}?t={1}", "~/Documents/Data/Acct/MyDocument.pdf", DateTime.Now.Ticks)>Document</a>
This produces a link that looks like: Content/~Documents/Data/Acct/MyDocument.pdf" which obviously doesn't exist because it's adding in Content and keeps the ~. If I remove the ~ I still get Content/Documents/Data/Acct/myDocument.pdf. How do I stop .NET from adding this Content/ to my link?
To add, the page that this link is in, is inside a folder called Views/Content. So I guess that's where it's being called from, but the ~ I assume should go up a level but it's not.
<a target="_blank" href=#string.Format("{0}?t={1}", "../Documents/Data/Acct/MyDocument.pdf", DateTime.Now.Ticks)>Document</a>
If you want to go up a level in your Url use ../ should get rid of the Content

Google Tag Manager - Event - Track Download on .aspx

I have an issue where I am trying to track the filedownloads on a website trough Google Tag Manager events. What I am doing is and already done on many websites is to find out if the "Click Url" contains any of the filetypes I am looking for like pdf, docx and so on. The issue here is that the Click Urls does not contain the information and are ending with .aspx. What is the best method to solve this issue?
I'd rephrase the question: what do these links (elements) have in common, that point to various downloadable files, and that is different from anything else, what is not a download link. This can be referred in GTM as a trigger.
Consider the following example:
<a class="button file_download" id="file_link_12" href="index.aspx?action=download&file_id=12">Download file</a>
If any of these can be identified in your HTML source code, then you can use these as triggers, which describes your elements used to point to downloadable files, e.g.:
Click Classes contains file_download
Click ID contains file_link
Click text equals Download file
Click URL contains action=download
If you are able to alter the HTML code, than you can choose any of these methods above, that bests suits your needs.

TideSDK popup "save to dialog" onclick <a href="">

Using the TideSDK, I am creating a desktop app for users able to view and save the file.
In my index.html I have over 50 zipped files which I would like it to prompt user "save to disk" when clicking on the link (as below). How do I solve this? Many thanks!
Example:
<a href="filename1.zip">save to desktop...
<a href="filename2.zip">save to desktop..
You could capture the click, use Ti.UI.currentWindow.openFolderChooserDialog to allow the user to choose a location to download the file too, and then use the Ti.Filesystem api to copy the file to the destination.

Resources