You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Jithesh A P <ji...@gmail.com> on 2011/08/25 19:58:57 UTC

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

Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
This would be a nice feature request :). I hope it gets out soon.

Regards
Jithesh



On Thursday, August 25, 2011 at 1:21 PM, Mark Herman wrote:

> FYI https://issues.apache.org/jira/browse/SLING-2166 (file upload limit)
> 
> 
> -----Original Message-----
> From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
> Sent: Thursday, August 25, 2011 4:11 PM
> To: users@sling.apache.org (mailto:users@sling.apache.org)
> Subject: Re: processing POST help - direction needed
> 
> Thanks Mark.
> 
> Regards
> Jithesh
> 
> 
> 
> On Thursday, August 25, 2011 at 1:07 PM, Mark Herman wrote:
> 
> > Not that I'm aware of. 
> > 
> > One thing I noticed, with the example I gave you, there are some limits
> with
> > request.getParameter() [1] (Servlet API) so you may want to use
> > slingRequest.getRequestParameter() [2] (Sling API) instead. That will give
> > you .getSize() and .getInputStream().
> > 
> > [1] http://sling.apache.org/site/request-parameters.html
> > [2]
> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPa
> > rameter.html
> > -----Original Message-----
> > From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
> > Sent: Thursday, August 25, 2011 3:44 PM
> > To: users@sling.apache.org (mailto:users@sling.apache.org)
> > Subject: Re: processing POST help - direction needed
> > 
> > A quick follow up question, i was browsing documentation and i think there
> is
> > no configurable parameter at present to set the max file size that can be
> > uploaded. I hope i am right, unless i missed something. If such a thing was
> > there that could have helped me as well :)
> > 
> > Regards
> > Jithesh
> > 
> > 
> > 
> > On Thursday, August 25, 2011 at 12:39 PM, Jithesh A P wrote:
> > 
> > >  Hmm ok. I don't have the virus api yet, i will be provided with one
> soon. 
> > > Let me start from this suggestion below and and get hold of some person
> who
> > can help me out with java as needed.
> > > 
> > > Thanks for the 
> > > 
> > > Regards
> > > Jithesh
> > > 
> > > On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:
> > > 
> > > > 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 (mailto: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)
> > (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


RE: processing POST help - direction needed

Posted by Mark Herman <MH...@NBME.org>.
FYI https://issues.apache.org/jira/browse/SLING-2166 (file upload limit)


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

Thanks Mark.

Regards
Jithesh



On Thursday, August 25, 2011 at 1:07 PM, Mark Herman wrote:

> Not that I'm aware of. 
> 
> One thing I noticed, with the example I gave you, there are some limits
with
> request.getParameter() [1] (Servlet API) so you may want to use
> slingRequest.getRequestParameter() [2] (Sling API) instead. That will give
> you .getSize() and .getInputStream().
> 
> [1] http://sling.apache.org/site/request-parameters.html
> [2]
>
http://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPa
> rameter.html
> -----Original Message-----
> From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
> Sent: Thursday, August 25, 2011 3:44 PM
> To: users@sling.apache.org (mailto:users@sling.apache.org)
> Subject: Re: processing POST help - direction needed
> 
> A quick follow up question, i was browsing documentation and i think there
is
> no configurable parameter at present to set the max file size that can be
> uploaded. I hope i am right, unless i missed something. If such a thing was
> there that could have helped me as well :)
> 
> Regards
> Jithesh
> 
> 
> 
> On Thursday, August 25, 2011 at 12:39 PM, Jithesh A P wrote:
> 
> >  Hmm ok. I don't have the virus api yet, i will be provided with one
soon. 
> > Let me start from this suggestion below and and get hold of some person
who
> can help me out with java as needed.
> > 
> > Thanks for the 
> > 
> > Regards
> > Jithesh
> > 
> > On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:
> > 
> > > 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 (mailto: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)
> (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


Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
Thanks Mark.

Regards
Jithesh



On Thursday, August 25, 2011 at 1:07 PM, Mark Herman wrote:

> Not that I'm aware of. 
> 
> One thing I noticed, with the example I gave you, there are some limits with
> request.getParameter() [1] (Servlet API) so you may want to use
> slingRequest.getRequestParameter() [2] (Sling API) instead. That will give
> you .getSize() and .getInputStream().
> 
> [1] http://sling.apache.org/site/request-parameters.html
> [2]
> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPa
> rameter.html
> -----Original Message-----
> From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
> Sent: Thursday, August 25, 2011 3:44 PM
> To: users@sling.apache.org (mailto:users@sling.apache.org)
> Subject: Re: processing POST help - direction needed
> 
> A quick follow up question, i was browsing documentation and i think there is
> no configurable parameter at present to set the max file size that can be
> uploaded. I hope i am right, unless i missed something. If such a thing was
> there that could have helped me as well :)
> 
> Regards
> Jithesh
> 
> 
> 
> On Thursday, August 25, 2011 at 12:39 PM, Jithesh A P wrote:
> 
> >  Hmm ok. I don't have the virus api yet, i will be provided with one soon. 
> > Let me start from this suggestion below and and get hold of some person who
> can help me out with java as needed.
> > 
> > Thanks for the 
> > 
> > Regards
> > Jithesh
> > 
> > On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:
> > 
> > > 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 (mailto: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)
> (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


RE: processing POST help - direction needed

Posted by Mark Herman <MH...@NBME.org>.
Not that I'm aware of. 

One thing I noticed, with the example I gave you, there are some limits with
request.getParameter() [1] (Servlet API) so you may want to use
slingRequest.getRequestParameter() [2]  (Sling API) instead.  That will give
you .getSize() and .getInputStream().

[1] http://sling.apache.org/site/request-parameters.html
[2]
http://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPa
rameter.html
-----Original Message-----
From: Jithesh A P [mailto:jithesh.ap@gmail.com] 
Sent: Thursday, August 25, 2011 3:44 PM
To: users@sling.apache.org
Subject: Re: processing POST help - direction needed

A quick follow up question, i was browsing documentation and i think there is
no configurable parameter at present to set the max file size that can be
uploaded. I hope i am right, unless i missed something. If such a thing was
there that could have helped me as well :)

Regards
Jithesh



On Thursday, August 25, 2011 at 12:39 PM, Jithesh A P wrote:

>  Hmm ok. I don't have the virus api yet, i will be provided with one soon. 
> Let me start from this suggestion below and and get hold of some person who
can help me out with java as needed.
> 
> Thanks for the 
> 
> Regards
> Jithesh
> 
> On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:
> 
> > 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 (mailto: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)
(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
> 


Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
A quick follow up question, i was browsing documentation and i think there is no configurable parameter at present to set the max file size that can be uploaded. I hope i am right, unless i missed something. If such a thing was there that could have helped me as well :)

Regards
Jithesh



On Thursday, August 25, 2011 at 12:39 PM, Jithesh A P wrote:

>  Hmm ok. I don't have the virus api yet, i will be provided with one soon. 
> Let me start from this suggestion below and and get hold of some person who can help me out with java as needed.
> 
> Thanks for the 
> 
> Regards
> Jithesh
> 
> On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:
> 
> > 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 (mailto: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) (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
> 


Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
 Hmm ok. I don't have the virus api yet, i will be provided with one soon. 
Let me start from this suggestion below and and get hold of some person who can help me out with java as needed.

Thanks for the 

Regards
Jithesh


On Thursday, August 25, 2011 at 12:10 PM, Mark Herman wrote:

> 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 (mailto: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


RE: processing POST help - direction needed

Posted by Mark Herman <MH...@NBME.org>.
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


Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
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


RE: processing POST help - direction needed

Posted by Mark Herman <MH...@NBME.org>.
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
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

Re: processing POST help - direction needed

Posted by Jithesh A P <ji...@gmail.com>.
 Hmm since i am not a Java person and pretty new into programming, want to see if i can circumvent my issue using .esp.

Regards
Jithesh


On Thursday, August 25, 2011 at 11:28 AM, Justin Edelson wrote:

> How about using a filter for this extra processing?
> 
> Alternatively, you could use a PostProcessor. At that point, the file
> node/properties have been created in the Session, but the Session has
> not been saved, so you can abort at that point.
> 
> HTH,
> Justin
> 
> On Thu, Aug 25, 2011 at 1:58 PM, Jithesh A P <jithesh.ap@gmail.com (mailto:jithesh.ap@gmail.com)> wrote:
> > 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


Re: processing POST help - direction needed

Posted by Justin Edelson <ju...@justinedelson.com>.
How about using a filter for this extra processing?

Alternatively, you could use a PostProcessor. At that point, the file
node/properties have been created in the Session, but the Session has
not been saved, so you can abort at that point.

HTH,
Justin

On Thu, Aug 25, 2011 at 1:58 PM, Jithesh A P <ji...@gmail.com> wrote:
> 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
>