sling-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Herman" <MHer...@NBME.org>
Subject RE: processing POST help - direction needed
Date Thu, 25 Aug 2011 19:10:47 GMT
The 3rd example of a POST.jsp gets you 90% of the way there, but I don't see
how you're going to completely avoid java.  
How do you plan on performing this virus scan?

Assuming you have some java based virus scan api, you can take the POST.jsp
they give you and replace this line:

contentNode.setProperty("jcr:data", new
ByteArrayInputStream(request.getParameter("myfile").getBytes()));

with something like: 

byte[] bytes = request.getParameter("myfile").getBytes();
if(bytes.length > 1024*1024*2 ) {
	//larger than 2MB so throw exception or something
}
if(AntivirusUtility.isDirty(bytes)){
	//infected so throw exception
}
contentNode.setProperty("jcr:data", new ByteArrayInputStream(bytes));
...


-----Original Message-----
From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
Sent: Thursday, August 25, 2011 2:31 PM
To: users@sling.apache.org
Subject: Re: processing POST help - direction needed

Thank you very much for the quick response Mark. I did have a look at that
link, but did not get an answer to what i was looking for. Let me elaborate.
Let me put it in simple terms (without getting into my need complexity :)),
What i need is
I have an HTML form to upload files. 
I can hand it over to sling to do the post after file is selected, 
but before that i want to check if the file has virus, 
or is within the permitted file size & type (this i can do with javascript,
but if there is a user who uses curl to upload, need to trap that)

After i trap and validate the file is fine for upload, i need to hand it over
to sling to finish the POST operation

I hope this gives an idea of the scenario. I am not a JAVA person, so trying
to see if i can accomplish this with something like POST.esp :).


Regards
Jithesh



On Thursday, August 25, 2011 at 11:22 AM, Mark Herman wrote:

> Not sure about "hand it back to normal POST operation" but this[1] may get
> you what you need.
> 
> [1] http://dev.day.com/content/ddc/blog/2008/07/fileuploadsinsling.html
> 
> 
> -----Original Message-----
> From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
> Sent: Thursday, August 25, 2011 1:59 PM
> To: users@sling.apache.org (mailto:users@sling.apache.org)
> Subject: processing POST help - direction needed
> 
> Hi Folks,
> 
> I am stuck at how to handle post of a file. For example i want to upload a
> file, do some processing like check for virus (during POST), then hand it
> back to normal POST operation.
> 
> Is it possible to achieve this using POST.esp and how?
> 
> Your input will be greatly appreciated.
> 
> Regards
> Jithesh

Mime
View raw message