I need to make an extension to Alfresko (SDK 3.0) that should upload file from an external source.
I've managed to create a simple tutorial extension (https://docs.alfresco.com/5.2/tasks/dev-extensions-share-tutorials-add-menuitem-create-menu.html) but i can't even guess how can i integrate a file upload logic there?!?
The main goal of extension is to uplaod a file, that is achieved from a simple office scanner. Scanning job is expected to be dealt with by a separate application, that after the job's done should return file via rest API.
I'm new to Alfresco, so could anyone please advice the approach i should use (or maybe point to an example) for calling and recieving data in Alfresco extension?
Related
I have common question about architecture I should use for my specific problem.
I have .TSV file with some informations and my task is to create REST API app that will consume this .TSV file and there will be 3 REST API endpoints. Each endpoint will return JSON data I processed from .TSV file.
My question is: Should I crate some POST method that will upload the TSV file and I will save it eg to the session and do the logic with using the API Endpoints?
Or should I POST the content of TFS file as JSON in every request to the specific endpoint?
I dont know how to glue it all together.
There is no requirement fot the DB. The program will be tested just with numerous requests through the API and I dont know how to process or store the .TSV content in my app so one user could call all three endpoint sequentially above the same data without reuploading the TSV file.
It's better to upload the file and then do the processing on server. The file will upload in one request and it's better rather than send multiple request.
I believe the solution will depend on the size of the file. Storing the file in the memory can not be a good approach if the file is very large. And also, saving the file in a session may not be good, because if you need to scale your service in the future, you will not be able to do it. Even storing the file in a /tmp directory can also be a bad approach, because the solution continues to be not scalable.
It will be a good idea using a Storage Service like AWS S3 or Google Firebase or any other related. When you would call one of your three RESTs, your application will verify if that file was not yet processed, read that file, process anything you want and save the result to your S3 Bucket (If you don't want to save the processed files, you can use a retention policy on S3 to delete the file after X period of time).
And only after this, you will return the result. As you can see, this is a synchronous solution.
If the file processing need a lot of CPU and takes so long, you will need an asynchronous solution. So instead of processing the files directly when you call the REST API, you will have to create another application that will read that file from S3, process it and save it. All asynchronously. And your REST API would only get the file from S3 and return it.
I want to use flash file stored on another server or repository. I am using below code in xsl to add flash file.
https://www.***.com/docs/swf/Spreadsheet.swf
The problem is I am unabele to create swfObject because that flash file is not getting loaded properly on browser. My xslt application is on another server which is trying to access .swf file using above code. I guess there might be domain related issue. I read somewhere about cross domain.xml file.
Is it really required in above scenario? If yes then where to keep that cross domain.xml file? The flash file that I want to access is on another repository which is not on any web server. So can anyone provide me solutions on this?
A well known constraint is that you should not use java.io in EJB's to access the file system. I need to create a text file and send it via email when a particular method is invoked in my ejb application.
I need an architectural solution on how to do this without using java.io.
The only approach I see is to create a separate web service for this job.
Also there was a suggestion to use Apache camel, but I don't know how camel can help to achieve this.
We found a way to avoid using the file system from ejb's by creating the files as ByteOutputStream in memory and sending them via email. This way we don't need to use the file system.
Similar example: Create a Zip File in Memory
I'd like to implement in my web application a file/directory upload similar to Google Drive style (I think it's the best example to explain what I want).
So I would like to upload:
a single file
multiple selected files
a selected folder (all files contained in it)
On client side I suppose I have to use HTML5, am I wrong? But How to handle this on server side controller. I'm using Spring MVC 3.2.9
Can you suggest me the best approach?
The hard part is the client side upload of folders. According to this other answer on SO about Does HTML5 allow drag-drop upload of folders or a folder tree?, The HTML5 spec does NOT say that when selecting a folder for upload, the browser should upload all contained files recursively.
Of course it is possible, but HTML5 is not enough and you will have to use Javascript to (recursively) find all files in the folder.
As said by conFusl, you can find a nice example on viralpatel.net Spring MVC Multiple File Upload tutorial. Spring Multiple File upload example. The princips are :
on client side generate (via javascript) a form with one <input> tag per file to upload, and give them names like files[i]
on server side, you then get a form containing a List<MultipartFile> that you can process as usual.
I'm planning a web application where users will be able to upload and process their files. The specifics of the application are irrelevant to my questions, but lets assume that the application will deal with mp3 audio files. I'm going to split my application in two distinct parts: the front-end and the back-end.
The front-end application will be a usual web application serving html pages to users. Typically a user will upload his file and fill an html form to specify which operations he would like to perform on the file. The files will be initially uploaded to a storage facility, such as Amazon S3, and later processed by a back-end server. I'm using Play 2.0.4 framework to develop the front-end application and this is going very well for me. I managed to implement user authorization, drafted most of the UI and also implemented file upload to S3. The application is currently deployed on Heroku without any problems.
For my back-end server I'm considering to use Play 2 framework once again. The back-end server will receive notification (http request) from the front-end server about creation of a new job. Job specification will include a link to the original user file in the storage and arguments describing the job. The job should be added to a queue. Now the most important part is to delegate the actual processing job to a third party program, which most certainly will be a compiled command line utility, such as SoX for the case of audio processing, written by good people using a programming language of their choice. As far as I know it is possible to call an external program from java, pass command line arguments and collect the result. After processing is done, the back-end server will upload processed file back to storage, and send notification (http request) to the front-end application, which will store a link to the processed file and display it to the user at some later time. To be able to use command line utility I'm going to deploy the back-end application to a Amazon EC2 instance with a Typesafe stack installation.
Here are some questions about this basic plan:
Is Play 2 a reasonable choice for the back-end, or should I look into alternatives? One of them seems to be CGI, which according to Wikipedia "is a standard method for web server software to delegate the generation of web content to executable files." Unfortunately I don't have any experience with that.
There shouldn't be any problem implementing a job queue with Play?
Is it possible to install a command line utility on EC2 and call it from Play?
Should I expect any problems installing Typesafe stack on the EC2? This post briefly describes what I'm planning to do https://www.assembla.com/spaces/bufferine/wiki/Typesafe_stack_on_Amazon_EC2
Assuming that in the future the application will grow, how would I split the jobs among multiple instances on EC2? Should I create a separate job-balancing application in between my front-end and back-end?
I would appreciate any advice! Thanks!
Note: I'm using Java api for Play 2 framework, since I'm not familiar with Scala language.
You may consider Akka for processing and it's built in Play2. It will help you to manage tasks easily, and even saving hardware ressources if used with advanced features. There is a Java API that should cover all your needs. And it's not necessary in a backend APP, if you need more power you can scale even better with two same instancies. Play and Akka are stateless, you can just add new instances to scale. To make it run on EC2, just use the play dist command.
And yes, you can install whatever you want in EC2 and call it from your app.
You may like:
http://akka.io/
http://www.playframework.com/documentation/2.1.0/JavaAkka
http://www.playframework.com/documentation/2.1.0/ProductionDist
also, but in scala
http://blog.greweb.fr/2013/01/playcli-play-iteratees-unix-pipe/
http://blog.greweb.fr/2012/11/play-framework-enumerator-outputstream/