How to create a file and make it downloadable in GWT? - google-app-engine

I want to export the data in a celltable to a CSV file. I understand this must be done in the server side. I'm a bit lost on how to create a file, write the lines and then make the client download it.
One it's served, it could be downloaded automatically or by a "Download" button, is the same.

If you just want to generate file and serve it directly you can create a servlet and hit the servlet url in a Window, You may want to take the same datasource and use it at the server side to convert it into a csv. Please follow along the steps as described in (Download a generated pdf from client) and for downloading that from GWT Window follow (How to download a file via a button click i GWT?),

Related

How to open a generated file on Vaadin Flow?

On my app I want to open a generated PDF with PdfBox on a new tab, I have seen a couple of documentations but they are for old version of Vaadin or won't work in my case. I don't want to save it on the server or attach the file to any link or button, I want to write a method to automatically open it on a new tab.
PdfBox gives an option to save the file on an OutputStream, is there any way to open that OutputStream file on a new tab? Or at least download it without attaching it to an Anchor widget like Flow Viritin does?
The problem lies in the fact that because you don't want to save the file on the server, you cannot then have a direct url of said file to link to. You also cannot pass the pdf file as parameter to another View.
The solution is to store the pdf in the VaadinSession (as byte[] is probably easiest), and when the user then opens another tab by clicking a certain anchor/routerlink, that view will read the pdf from the VaadinSession and add the it to the view. (How to display pdf with Vaadin 14). Please remember to remove the pdf again from the VaadinSession :)

How to get file download complete status using selenium web driver c#

I am writing a automation script using selenium web driver for downloading multiple files one by one from a web site in Mozilla fire fox. I have downloaded first file successfully and next time I need to wait for download to complete. Can anybody help how to identify an ongoing download is completed using c# selenium web driver.? Since I am not getting the download complete status, I am unable to continue downloading next file.
Assuming you are testing file downloading in Firefox as you mentioned. Here is an approach to achieve what you want.
Open new window/tab in Firefox and navigate to 'about:downloads' directly.
i.e. driver.Navigate().GoToUrl("about:downloads");
You will get the list of downloads (i.e. already downloaded files and the file which is being downloaded currently.)
You will have to switch between your site tab and downloads tab.
Now on downloads tab, looking at HTML, you can easily find out in progress download using state or status attributes.
For example, for the first file in the list, if state="0" and/or status
contains the text 'remaining', it means downloading is in progress
So you can wait till state becomes state = 1 and/or status does not contain >the text 'remaining'
Refer the attached screen shot.
The explanation I gave here looks very high level, but I am sure this approach will work. It is simple too.
Let me know if you have any queries on this.

How to convert the uploaded file in Box.com?

https://salesforce.stackexchange.com/questions/45823/how-to-download-uploaded-file-in-box-com/46515#46515
In the above link the code will give an url (in the response) to download the file. But i want the file to be downloaded in HTML format. As per the box.com website i.e., https://developers.box.com/view/ they have given that we can convert the files to HTML. How can i do this using salesforce.
#Srilakshmi B S
If you want to download the file as HTML, you'll have to take the file and send it to the Box View service/API for conversion. The Box content API doesn't by itself allow you to convert documents for preview and download into HTML. That means that you'll need two separate tokens if using both API endpoint. If you are in fact planning to use both, there's some documentation here on how:
https://developers.box.com/using-the-view-api-with-the-content-api/

Getting images with HTTP Request in C

I am writing a program in C that acts like a proxy server in a Linux system: Client asks it for a web page,
it sends an HTTP GET Request to a distant server, and it gets the servers response (web page), which is saved in an .html file.
Here goes my problem: Most web sites got some references to images, so when i try to view the .html file proxy created, the images don't appear.
I have searched a lot, but found nothing..Is there a way to write some code to GET images too?
Thank you in advance
You're going to have to write code that parses the HTML file you get back and looks for image references (img tags), then queries the server for those image files. This is what web browsers are doing under the hood.
You have an additional problem though which is that the image references in the HTML file are to the original server. I'm assuming that since they don't load for you the server that returned the original HTML isn't available. In that case after you get each image file you will need to give it a name on the local filesystem and then alter the reference in the HTML (programmatically) to point to your new local image name.
So for example:
<img src='http://example.com/image1.png'>
would become
<img src='localImage1.png'>
If you're querying arbitrary websites then you'll also find that there are various other files you'll need to do the same with like CSS files and JavaScript files. In general its hard to mirror arbitrary web pages accurately - browsers have complex object models they use to interpret web pages because they have to deal with things like CSS and Javascript and you may need to be able to 'run' all that dynamic code to even be sure what files to download from the server (e.g. JavaScript including other JavaScript etc).

Silverlight and XtraReports - opening generated PDF report in new tab in browser

I'm trying to send a PDF file from a WCF to silverlight client. PDF is generated by DevExpress XtraReports (in method XtraReport CreateReport(string reportTypeName, RootGenericReportParameterContainer reportInformation)).
Acually PDF is saved somewhere on clients computer after choosing save path in file save dialog - DevExpress takes care of everything - but I don't have a clue how to open the PDF in new tab in browser.
And here is another problem. Silverlight 4 has no access to local file system right? So information about local PDF location is useless. Maybe it would be better to save the PDF in WCF and send a link to it to the client - but how?
I would first question why you need to send the file to the Silverlight client. Get rid of that requirement and the solution becomes much simpler. Silverlight can provide a link that opens a new browser tab. That link would be handled by the web domain, processing it as an HttpHandler, generating the PDF file for the browser. Your PDF url doesn't have to reference a physical file, you can still generate it on request, handle querystring values, etc... Lots of different ways to do this.
Seems that the question isn't really about DevExpress or Silverlight - you're just looking to open a [document of some kind] in a new tab. Each browser natively handles things differently, and users can change tab handling to whatever they want. And (as you mentioned) once the user has downloaded the file, you no longer control it.
Your best bet (and the way I do it) is probably to have a link pointing to a handler/file using "target='_blank' " in the anchor tag on the webpage. From the server side, you would want to set the "Content-Disposition" header to "Inline" to indicate to the browser that the document should be displayed in place instead of downloaded ("Attachment").

Resources