Streaming HTML file along with images using java - java

I have a HTML file which has images. I want read this file from local folder like C:/data using java and display it on browser along with images when request comes from client(other than localhost).

Related

How to download file from a "Download" folder using postman or API

In my application, after clicking export icon, the report excel has been downloaded/generated in our local download folder in the system. I have tried to validate this action using service side (API)-postman. When I hit the export api (Application specific) , the response has not contain any path/file name that downloaded in the downloads folder. Is there any way that we can hit the downloads folder using api or any java programming way to get the downloaded excel.
I just want to read the excel data and compare with my input data using postman. First priority that I need to do it using api.
Select "Send and download" action in Postman. According to manual here:
If your API endpoint returns an image, Postman will detect and render
it automatically. For binary response types, you should select “Send
and download” which will let you save the response to your hard disk.
You can then view it using the appropriate viewer. This gives you the
flexibility to test audio files, PDFs, zip files, or anything that the
API throws at you.

Retrieving data from web browser's download manager using java

I want to try creating a program that can automate the storing of web address that is available on every downloaded file on a web browser.
My problem is I don't know where to start.
What am I planning to do is just save all the downloaded file's web addresses in a excel file.
Sample image using google chrome
I think Firefox stores the download history in the places.sqlite file in your Profile folder. You would need to open and read that file, but you probably can't while Firefox is open (it has the file open).
http://kb.mozillazine.org/Places.sqlite
From there, you can process the data in your Java app and then write an Excel file, perhaps using Apache POI (the Java API for Microsoft Documents)
https://poi.apache.org/
Where and how, download history is stored varies from browser to browser . In case of Chrome on Mac it is store in the path
~/Library/Application\ Support/Google/Chrome/Default/DownloadMetadata
as SQLite format.
You need to write an application to parse the data and create xls

Pass File from Javascript to Java Uploader Applet

I've got some Java Applet that I'd like to use to upload file/files to FTP server. Most important method is upload( String ftpServer, String username, String password, String filePath, File sourceFile ).
In JS code I've got stored in array data grabbed from input="file" (user can attach and remove files to different objects he created before, so I have to store this data somewhere).
The problem is that file data is represented by JS File object, when calling upload function is recognized as sun.plugin2.main.client.MessagePassingJSObject (same thing when trying to initialize new java.io.File object).
So questions are:
is there possible to pass somehow object compatible with java.io.File or data about file (I guess only the fullpath) to Java applet ?
if not is there a way to upload from Java code file readed with FileReader to String (for example with .readAsBinaryString method) ?
or if exist any other solution for my problem ?
Edit:
A little more context:
Ftp upload applet is a part of application that uses canvas element (and fabric.js library to be specific). User after adding new elements to canvas area can choose an element and add/assing some files to that element (any image files). Images don't have to be load into canvas area, just their names should appear on a list below canvas when specific element is selected. Of course they can be removed as well.
After user confirms that he finished some data is send (post) to server-side to prepare a control file, than upload this file to ftp server. The only information about selected files required in control file are filenames, so I think it's possible to add file chooser to applet instead JS code, than send that data from applet or pass it to javascript and than send. Before or after posting control file data all files selected by user should be also uploaded to ftp server.
Unfortunately, there is one case when a file have to be loaded into canvas and send to ftp server as well after confirmation - background image file.
I don't know any ways to pass HTML5-created ArrayBuffer to applet via Live Connect, but it is possible (and probably slightly more cross-browser compatible) to spawn Java file chooser and read file from disk, using applet (with JNLP FileOpenService you can do it without signing applet).

Showing JFree chart image from local machine in a web application

I am generating a chart using JFree charting library. After generating it, I am saving it to the local machine(The requirement document specifically reads that I have save it in local machine).
Now there is an a drop down in the Web UI, to export the generated image to excel or to render the image in Web page itself.
Since I am saving the image in the local machine, the img src html tag, does not work.
Is there any way to get around the problem ?
Server used : Weblogic
You need to programatically read the contents of the file from the disk and serve it through some servlet using stream , and set the url of the Img tag in page to this servlet .

Writing file from PHP page android

In my project a compressed file is displayed on a php in bytes.
I am trying to find a way to read the php page, decompress the file using GZIP, and write it out to the assets folder.
The file that I am reading in has to be placed in the data/data/package/database file.
I have a class that reads a file from the assets folder and places the file into data/data/package/database.
Is it possible to write to the assets folder during runtime? If not is there a better way to do this?
if the PHP script is running on a server, your Android app will need to make an HTTP request to retrieve the content. of course then it has to store it somewhere. the SQLite database is a good option, but you could also store content in files on the SD card.
there are a couple ways to do the HTTP connection part of it, and they're written up on the Android Dev Blog. Myself, I prefer the HttpURLConnection.

Categories