I am using GAE with Java to dynamically create a "text file" based on information provided in a form. With the form parameters, I successfully generated a String that should serve as the text in the txt file. However I am not sure exactly how to get that String in an easy to read format. Ultimately, I would like to have an iOS app be able to read the text. These are the two routes that I was thinking of using, but I've encountered problems with both.
Store the text in the database then showing that in another page. Unfortunately I exceed the 500 char limit for a String with GAE. I then tried using the Text class, but as it's not queryable, I'm not sure how to access it from a jsp page.
Dynamically generate a text file with the String of file contents. This option seems more of the "right way" by actually creating a new file. To be quite honest, I just don't know how to do that. I have looked extensively online, but have not found an answer. I've looked into Blob API, but what that allow me to create a brand new file that can be accessed at another URL location? Most of the documentation deals with images or other file types.
All responses are very much appreciated.
Thanks.
For 1, just remember the key of the entity, and fetch an entity with that key afterwards. For 2, you can serve text files as well. Now we're offering Google Cloud Storage integration, so it might be a better option.
Related
I've been trying to do this in a liferay module project. By making an input type=file in my view.jsp and saving it in a java File variable but i can't get it to work. Is this possible? and if yes, how?
So far i've looked for a paramutil method that i can use but there don't seem to be any. And i've tried to use request.getParameter but this doesn't allow for the type File to be used. After that I tried to create a upload request and fill it with the data from the form. But this also didn't work for me.
I wanted to make a form in my jsp file and let people upload a file via the input and let my java code run on submit to add the file to the documentlibrary.
A java File (as in java.io.File) is an abstraction for a pointer to something sitting on your file system. When you upload data in a portlet or any other means in a web application, you're first dealing with a stream of data that usually has no representation on the hard drive (unless you explicitly store it there). Thus, ParamUtil will not reveal anything of type File, because that's - by definition - not part of a http request.
There is a lot of upload sample code, that you might need to adapt to the version you're running (for example this) - but you'll first need to understand that you're not looking for any representation of data on your hard drive.
How to programmatically write json data into json file, located in Documents and Media of Liferay?
I have a portlet, in which I am receiving json data. I want to write the received json data into a json file located in Documents and media of Liferay portal.
I am able to write data into physical file path inside a portlet. But not able to find the physical file path of folder in Documents and media. I know it is in data/document_library. But not able to find the folder id.
Also file is encrypted with version number.
So I think it won't be of any use even if I get the folder id properly.
Can you guys suggest any feasible solutions on the same. I am new to Liferay.
Looking for the physical path of the file is plain wrong. Instead, use Liferay's API to store files in the Document Library. Watch out for API interfaces starting with DL, e.g. DLFileEntryService. There are plenty of examples for interacting with that API.
Storing files in data/document_library is one option (the default configuration) but the data can be anywhere else on disk, in a database or in other system. Plus, the metadata is always in the database. And it only gets there when you use the proper APIs.
I'm a java developer using Tapestry5. I'm using a jQuery plugin to manage my file uploads via ajax.
I'm looking for the best approach to temporarily saving the attachments until the actual page has been saved. My current work flow consist of a user uploading / removing a file with either the ajax upload box or an ajax remove link positioned next to the file like gmail attachments. I do not want to commit the file to the database until after the file has been uploaded and the save action within the form has been clicked.
I'm currently uploading the files and saving them to the user session until the save action within the form has been clicked. This works perfectly fine providing only one tab is in use, however I'm not sure that is the best approach.
Does anybody have any additional suggestions?
I've had to do something somewhat similar, but, with a slightly different stack (ASP.NET MVC).
The way I solved the problem was by generating a GUID on the page load and stuffing it inside of a hidden input. Your data store could be whatever you want (session, database, disk, etc - just be sure to include the GUID as part of your key). When the user saves the form just be sure to include your hidden input data and then you will have a unique way of identifying the files that were part of that instance.
What you are doing so far seems right, and you are also right that you could run into trouble if the user attempts to use your web app within multiple tabs. What you could do is :
Obtain a unique key before any file is uploaded with an ajax call. (note: as user #Ek0nomik suggests, this could also be included in a hidden input property when generating the page)
Whenever a file is uploaded, make sure to also submit this key.
When the form is saved, the key is submitted, you then know which files should be committed in the database.
I have a web application in GWT and a complementary desktop client also written in Java (so the same solution basically applies to both). In my program users can attach files, then download them later or do whatever. These files are stored as blobs and can be in just about any format. Many of the users that use Excel and Word want to be able to open the file, make changes, then have those changes stored back in the attached file. In other words, need an inline editing of attachments.
Any ideas on how to make this happen? Should I have an 'edit' mode that keeps a file handler while the file is open, and then store that File handler? Some way keeping track of whether the file is changing, or not?
Sorry about the late response. Amol >> I have that going. I want to save directly back to a blob as if it were a filehandle. Thought that was clear in my question.
I have decided that this is almost impossible with a web application without writing some kind of client interface for each and every potential file type - word, excel, pdf, graphics, etc...
I need to know how to perform the procedure, you already have read in the title.
You'll upload an image (e.g. a piece of text, an article) and on server-side the text will be recognized via OCR and stored into a database.
Which would be the best programming language for it? It should be a browser application.
I found the ocropus project, but how can I combine it to common web scripting languages like PHP? Is it possible at all? Didn't have worked with Python yet.
Or a totally different approach..? Java Enterprise?
Let's rock that,
Chris
maybe you can use this php library i use for recognize text from images and store the text readed into database
http://www.phpclasses.org/browse/package/2874/download/targz.html
download the rar package and run example.php and then example1.php to see how it works
here you have an image upload example:
http://www.reconn.us/content/view/30/51/
hope this helps