How to write a webscript in Alfresco that returns a zip file - alfresco

I need to write a webscript in alfresco that returns to the user a single zip file that contains several files, some of them created on the fly by the script and some of them stored on the server.
How can i do it?I know how to create different files on the server, i don't know how to zip them and how to include files that are stored on the server.

Well, you can develop a Java action that would do the zipping part.
Last time I was looking into this, I didn't find an out-of-the-box solution.
As for returning, you can specify that by specifying webscript format, ie:
<format default="html">any</format>
Only, there is a problem, you can't set a zip format, but alfresco wiki says how you can add more:
http://wiki.alfresco.com/wiki/3.0_Web_Scripts_Framework#HTTP_Response_Formats
Edit: I just found this thread (while looking for a solution for another problem). In the thread a custom "unzip" action is described, maybe you can use that to add a zip/unzip action in your alfresco installation and use it.

Related

Custom Report in alfresco?

Currently i am generating a report (we are getting files are uploaded within a time stamp).
I am getting all files and folders.Iterating the result and checking created date one by one.That is taking too much time approx 8 min to revert with resuls.Can anyone tell me is there any alfresco report api that i can use? or using solr how to fetch the result?
I like to follow an approach which is maybe not really orthodox. Usually, you don't want to report on all documents, only document using a specific type or aspect. So, what I do is to create a Java behaviour on onCreate, onUpdate and onDelete that updates a custom database with only the metadata that I'm interested in. Then, I can connect any OOTB reporting tools such as Pentaho, Jasper or Tableau. You have of couse some other traditional alternatives, such as:
Using this module developed by a community member: http://fcorti.com/alfresco-audit-analysis-reporting/
Or using the module provided by Alfresco: http://docs.alfresco.com/analytics/concepts/analytics-using.html
SOLR/Lucene is not an option, querying DB directly is not an option either (performance wise).
I would suggest using one of the options available (AAAR for instance) or developing something on your own following the same principles.
I did little bit investigation on this and found below link.
http://docs.alfresco.com/4.0/tasks/audit-recording-values.html
I think you can user auditService in alfresco and get your things done.There are few alfresco webservices(related to audit) already available which will allow you to filter response.In case if you need to customize it , than you can create webscript and use auditService in it.
You can use below url for browsing all your alfresco webservice.
http://localhost:8080/alfresco/service/index

how to create a new folder using alfresco api

I have uploaded sample.zip file in this directory CompanyHome/site/testsite/documentlibrary/test.
Now I want to create new folder called childfolder under above directory [CompanyHome/site/testsite/documentlibrary/test/childfolder] and move the sample.zip under it.using Alfresco API how do i create child folder and move the file under newly created childfolder?
This really depends upon what version of Alfresco you're using and what API you want to use to do it. For example, assuming that you want to do this via a REST API then you have the option of CMIS, the recent "Public API" or the internal WebScript based API.
Alternatively, you might want to do this by using the JavaScript API and WebScript develop your own WebScripts.
There are lots of ways to achieve this - perhaps you can provide some more information on the overall picture of what you're trying to do and where you're trying to do this (e.g. as an extension of Share maybe?).
It's possible to create a folder within Share and if you do so whilst you have browser developer tools open you'll be able to see the exact REST API calls that are used.

Upload Image file using Symfony2 without guessers?

I am using Symfony2 framework for one of my project. In this one, I want to upload an image. This is really easy to do so while following the Symfony2's cookbook. It works very well on my local machine. But when I put the whole application on my remote server (Planethoster.net shared hosting), it doesn't work because of the Type-Mime extension guessers. In fact, they are not enable on their servers... (phpinfo shows --disable-fileinfo)
So, basically the idea is to know if there is a solution to do the same action (uploading an image) without any extension guessers?
Thanks
What do you think of filtering the filename ? With the last three characters, you'll know the extension. Check out UploadedFile, there is a getClientOriginalName() method. What I would do is to explode it by the ., fetch the second entry of the resulting array, and then parse it to do what you want to do.
Would you like an example of code ?
To fix exception while uploading file using framework Symfony 2
Unable to guess the mime type as no guessers are available.
enable PHP extension php_fileinfo, to do this find your php.ini file and uncomment following line
; windows
extension=php_fileinfo.dll
or
; linux
extension=php_fileinfo.so

asp.net Web API retrieve file(s) without saving them

I want to retrieve file(s) with ASP.NET Web Api, XML file(s) or zip file(s).
There are many examples how to do this, like this:
http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2
But the problem is, I don't want to save them on HDD!
I just want to validate the XML with some functions and generate a report on the fly and want to return this report.
But every tutorial use the "MultipartFormDataStreamProvider" witch save the files on HDD.
How can I get the file(s) and file name(s) in memory?
Kind regards
I think you can use the MultipartMemoryStreamProvider?
See a way to implement file upload without writing to the file system.

How to create and write data into a file using flex3?

I want to create a file and write some data (userid) into the file at first run of my application, during the second run all the operation (will go to the next state) based on the file data, is it possible? How to create and write data into file?
It depends if you're working on a pure-Flex or an AIR project.
If you are making an AIR application, you can access local files using the File class (more informations can be found here and here) ;
If not, you'll have to use a server-side script (PHP, ColdFusion, Java EE...) to do the job, calling it using a HTTPService object for instance.
If you are not concerned about file's location and max content of file is less than 100 KB then you may make use of Shared Objects in flash.

Resources