I am in an situation where i need to run one command-line tool for file which is uploaded in alfresco repository.The reason behind this is i need to perform OCR on that particular file.
I know i can use transformation which alfresco by default provides.But transformation does not provides conversation between same mimetype and my requirement is like performing OCR on PDF File(which contains images) and again generate PDF File(Which contains extracted data).
My approach is to create a policy, when node is uploaded in alfresco repository.
From that policy I will access the node which is uploaded in alfresco repository using java,Here is the problem ,I dont know under which location of alf_data directory the file is getting uploaded.As i need to get physical location of file.
By the way I am using linux system.
Can any one help on this?
You need to use the ContentService, specifically getReader(NodeRef,QName) then getContent(File) to a temporary file
Your code would then be something like
File tmp = File.createTempFile("for-ocr",".tmp");
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
reader.getContent(tmp);
// Run the OCR program here
tmp.delete();
Related
I know that I can use a BLOB or an XML file, but I was wondering if there was a better way to do this, or if either of these are the correct way of doing this. The user should be able to edit their file online and then save it onto the server, and at any time get the file back into the editor and continue editing that file (similar to that of Google Drive). Any ideas? We are using Spring Framework and controllers for our site. We are using a MongoDB for file storage (files are stored on the server, file paths are stored on the MongoDB).
Using Android PrintManager API user can save content as PDF into device's internal/external directory.
I need to get that PDF file's path as soon as it is created. Is there any way to do this directly without having to use a file chooser?
Any ideas are appreciated.
Using Android PrintManager API we can save content as PDF into device's internal/external directory.
No. The user can elect to send your print job to a PDF file that is stored locally. The user could elect to do something else:
Send it to an actual printer
Send it to something else (e.g., Cloud Print)
Abandon the print job
Is there any way to do this directly without having to use a file chooser?
No, simply because there is no requirement for the user to save the content to a local PDF file in a place that you can access. In addition to all the above non-PDF alternatives, the user could save it as a PDF to removable storage, in a directory that your app cannot access.
I need to get that PDF file's path as soon as it is created
Then the PrintManager API is not suitable. Generate a PDF some other way (e.g., iText).
I have a swing application that uses many data files, these data files will change time to time. How can I load these data files on client's machine? Is there any way to create a folder like structure and run a batch file or so? Any help is appreciated.
There are several ways to do this:
Assume you want to ship your application with the datafiles, you may embed them as a zip/jar in your application-jar-file.
Extract the embedded zip to a temporary local file and use ZipFileSystemProvider to extract the content to some place on the disc.
Here is an example how to extract some content from zip/jar-file embedded in a .jar-file downloaded by JWS.
Same as 1, but skip the zip stuff and instead provide a list of all the resources you want to extract
One other way is to create the files pragmatically using either java.nio.file (java 7+) or java.io.File
I'm trying to create an app and have the ability to save files to /data/data/(packagename)/files or a directory similar to that. The goal would be to have a pdf or doc handler, as necessary, open the files stored on the internal storage and be viewed by the user. I have the code to get a pdf reader that is installed and display the file but I do not know how to package the files so they are installed in a directory like the one above. Also, if I am able to do this would I use getResources to access the files? How should the file structure look in eclipse to make this happen on install of the APK?
I do prefer to have the files stored internally (they are small) and not on the SD card.
I admit I am new to this and am trying to learn as I go. Thanks for the help!
As I understand your approach you only need to place your files to assets folder of your application and then just copy them to the internal storage. Read more here.
According to current requirement,user will upload files with large size,which he may like to download later. I cannot store the uploaded files in DB because the size of files is large and performance will be impacted if I store uploaded files in DB.
Any one knows any java plugin which provide efficient file management on webserver and maintains the link to file so that the file can be downloaded when the link is requested. Also the code will make sure that user will be able to download only those files which is uploaded by them,they cannot download any file just by modifying the download link etc. I am using spring3 as the framework.
Please suggest how to solve this problem?
if you have write access to the file system why not just save them there ?
you then generate an unique ID and save the hash/file relation in db, you then need to supply the ID to get the file feed from a servlet
Store the file content on a part of filesystem out of web application so you cannot reach it changing the link.
Then you can store on db the path for that file, and return them only if the user has the permissions to read it.
Pay attention, do not store all the file on the same folder, or the number of files could grow too much. So find a way to store them with more folder levels.