I'm making an intranet page where the users will put in some information (text). My application will take this text and go through files on a shared drive that the webserver has access to. Based on the text and some logic it'll find the file that matches.
Now that I have the full absolute file path of the matched file, I'd like the users to be able to download the file from the page as well. However, since the file doesn't exist in my application I can't serve it.
All I have is the network share like: \\somenetwork\share\filename.pdf
Is there a way I can let users download this file (with the above path) from the intranet page?
I've tried:
<a href="\\somenetwork\share\filename.pdf"> but that does not work.
also tried prepending file:// but that link does nothing. not even open the file or give the option to download.
PS: I understand that this should ideally be a script on the command line. I'm just trying to turn a command line script into an intranet page.
This works in chrome and ie. For a txt file on a shared drive (that I have access to), it opens the file in the browser.
test
You have to ensure the user has access to the shared drive for this to work.
Otherwise you'll need to host the file somewhere (e.g. via the webserver).
Related
I 've created a servlet to let users download a file . When the file is downloaded , I want it to be ReadOnly so that the user can't modify its content . So I've used the java.io.File class :
downloadFile.setWritable(false);
but I realized that the user can unset the read only flag after downloading the file .
What can I to prevent unsetting the read only flag?
I've created a servlet to let users download a file.
That servlet will be running on the web server. It's not running on the user's local computer - so it can't change anything about the user's local file system. Even your downloadFile.setWritable(false) won't operate on the user's local file system - the file will be saved by the browser, and the user gets to do whatever they want with it.
Even if you are running some app separately to your service, it would be not only hard, but pretty unfriendly to create a file which the user couldn't touch on their own system. You could try to run your app as a separate user, and give appropriate permissions to both the file and the directory it runs in - but then if the user has access to an administrator account, they'd still be able to override that.
As a user has downloaded your file, he can do anything with this file. If you are concerned about authenticity of the downloaded file, then consider data signing.
Sign your file using key, that is stored on the server and which is not available to end user.
To verify the file authenticity implement a servlet with functionality described in the link above.
I am new to Google App Engine. I ran (locally) the sample of GAE bolbstore application given in the below link:
https://developers.google.com/appengine/docs/java/blobstore/
It launched a page to choose and submit a file. When I choose a file clicked the submit button:
i) the browser automatically downloads the same file. Why is it again downloading the same file?
ii) it created two files inside the folder 'appengine-generated'. They are:
d06-XwWoSZVw9HRcnLjZiA
local_db.bin
What are these files and where did my file store as blob?
Don't worry too much about what happens locally on the dev server.
i) It's just part of the demo, it serves you back the file you just uploaded because of this line:
res.sendRedirect("/serve?blob-key=" + blobKey.getKeyString());
ii) The first would I guess be the file you've just uploaded, the second would be the local copy of mySQL the dev server is using to emulate the datastore itself. Try comparing sizes to the original file you uploaded?
Once you have stored the file you have to access it via the api's provided, what form and where the file is actually stored no longer matters.
I have developed a website, one of its operation is to read and write data to text files stored at my local machine such as D://test.txt or C://file.txt, but now I am going to host my website at the external server, i mean over the internet use, i wonder where to keep these files that are associated with read and writing operations. At present I am getting an exception file not found if i am using my local machine location. For your information, I am using GlassFish server.
You will want to create a system property on Glassfish, which represents the file path and name. Then upload the file to that location of your choosing on the server where your website application is deployed.
Depending upon your needs, you may find it easier to deploy the file out with your application. Make sure the file is on the classpath, and you can load it using any number of ways.
I need to create a list of links on my JSP, related to some files that are in a specific folder (with html extension), on a Unix server.
My questions are:
How do I "connect" to the Unix server? My JSP will be stored on the same server that I need to search into.
What method I should use to search through my specific folder?
You can use the File.listFiles(...) method (on any OS/filesystem actually). Be aware that there might be limitations if the uid for webserver has no access to the folder/files or is eg. in a chroot'ed environment on the UNIX box.
The following code snippet
File[] files = new File( "/your/folder" ).listFiles( "*.html" );
should give you a File[] array with the files satisfying the .html condition in /your/folder.
Cheers,
You could do this in several ways.
If the share on the server is local or locally mounted already, then you can use Anders R.Bystrups answer.
If it is not, then you need some method of connecting to the server.
If it is a shared resource (a shared folder, for example), then you can access it with //server/share/file).
If the server is running FTP or SFTP, then you can use the relevant service to retrieve the list of files.
Finally, the server could run a web service (which you would have to write) which could expose the list of files it has.
We have a web application that allows user to download a zip file from a web server. We just provide dummy iframe source to the full URL of zip file on web server. This approach would allow end user to use browser controls which allows the user to open or save the zip to user's local machine.
We have a requirement that the zip file is automatically extracted and save to a specific location on user's machine. Any thoughts on how this can be achieved?
Thanks.
I highly doubt that you'll be able to do that. The closest you're likely to get is to generate a self-extracting executable file (which would be OS-dependent, of course).
I certainly wouldn't want a zip file to be automatically extracted - and I wouldn't want my browser to be able to force that decision upon me.
Short answer is I don't believe this is possible using the simple URL link you've implemented.
Fundamentally the problem you have is that you have no control over what the user does on their end, since you've ceded control to the browser.
If you do want to do this, then you'll need some client-side code that downloads the zipfile and unzips it.
I suspect Java is the way to go for this - Javascript and Flash both have problems writing files to the local drive. Of course if you want to be Windows only then a COM object could work.
Instead of sending a zip file why don't u instruct the web server to compress all the web traffic and just send the files directly?
See http://articles.sitepoint.com/article/web-output-mod_gzip-apache# for example.