How to download pdf automatically with an url - ruby-on-rails

I am using Ruby2.6.0, Rails5.2.3 and Kibana6.6.1.
I need some help to realise pdf download automatically. Is there any way to download pdf/png automatically using the following url in controller? 'automatically' means users won't feel the file download and don't need to click download icon.
http://localhost:5601/api/reporting/jobs/download/jvhs9dga06559d006260ms70
Edit:
Add the code I tried. It helps me to download a file. But I cannot open it with Chrome or sublime. It seems like the file is related to kibana Chromium sandbox (https://www.elastic.co/guide/en/kibana/current/reporting-chromium-sandbox.html). Is anybody know what type of this download file is and how to open it? How to save it as pdf/png file in my local folder?
File.open('./public/testfile.png', "wb") do |file|
file.write open("http://localhost:5601/api/reporting/jobs/download/jvhs9dga06559d006260ms70")
end

Related

Hosting MP3 files in rails without auto downloading them

Im building an API and I need to host MP3 files.
I have used active storage to upload the MP3 files and that all works fine, however when I create an endpoint with a url to the MP3 file, that URL just downloads the MP3 file rather than taking me to a page where I can listen to it.
Im trying to replicate the behaviour seen here:
MP3 link
Does anyone know how I can achieve this in rails?
Any help is much appreciated.
When you use send_file without a type, it will download the file raw.
Instead, you must specify the type of file so the browser knows how to handle it. For example:
def download
send_file "/path/to/file.mp3", type: "audio/mpeg", filename: "file.mp3"
end

How to download the grass style file in Neo4j?

After using :style command to get the file, I can't edit it directly in the browser, or I can't download it. I have to copy and paste it to my local file, edit it and then upload again.
How can I download it?
Is it possible to edit it without downloading?
You cant download it anymore as far as i know. Also you cant edit it in the browser itself. But you can still just copy it into your own *.grass and drag and drop it into the tab with the star.

force "save file" on download URL

I have a template file saved in my Microsoft SharePoint document library, I am using a promoted link tile (linking directly to the file in the SharePoint) to make it easier for users to download it.
Problem is, I don't want people to open the file directly, but to force them to save the file first. Is there any way to do so just by adding something in the URL ?
In HTML5, most browsers you can add a 'download' attribute to the a element.
for example:
Download
Refer: How can I create download link in html?
Yes, there it. Add "/_layouts/download.aspx?SourceURL=" after the site name.
If the direct URL is sp.contoso.com/SharedDocuments/myfile.docx, then the download URL is sp.contoso.com/_layouts/download.aspx?SourceURL=/SharedDocuments/myfile.docx

Need download file from URL in my custom path Programmatically by java in SWT

I am using below code to open url and download something from this url. After that downloaded file should be save in my path mentioned in second parameter.But by this code when i perform download, the download file saved on browser default setting path. How to save download file to my own path.
Program.launch(url,my path);
org.eclispe.swt.Program.launch(url,path) opens the default operating system executable associated with the url (the browser in your configuration). The second parameter is the working directory for the executable and has nothing to do with the download directory of your browser.
If you only want to download something from an url please look at how-to-download-and-save-a-file-from-internet-using-java.

.txt file on server wont open but same file changed to .css does?

Basically I get an error every time I try open or get this txt file via url. However when I change the extension to css it opens fine. I have tried re-uploading and it makes no difference.
Try for yourself:
http://seanbingley.comyr.com/DrKruseSite/articles.txt
http://seanbingley.comyr.com/DrKruseSite/articles.css
Thanks in advance.
Edit:
I should probably state that I am not bothered about actually opening it in a browser. I need to read data from it for my website. However I cannot read the data if it keeps giving me 404.
Also when opening the txt file locally in a browser it works fine. It's just when I try to open the same file from the server it goes wrong.
You have to add a mime-type on IIS so it can read it.
Okay so the hosting site (000webhost) does not allow txt files on free accounts.

Resources