File access in the FileBean

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

File access in the FileBean

Heather and Jon Turgeon
Hello all, I am trying to use Stripes in an app that will be hosted on Amazon's AWS. I want to allow file upload and am running into a bit of a problem. Amazon wants me to store the file on S3 passing a byte array. It seems easy enough to do this if I were to have access to the File object in the FileBean, but it is private. So, any thoughts as the the easiest way to gain access to it while in the temp directory? I am trying to minimize the changes I would need to make to the framework. Thanks

Jon

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: File access in the FileBean

Adam Stokar
If you are using the AWS Java SDK, you can upload a file to s3 by sending an InputStream (see the PutObjectRequest).  the FileBean object has a getInputStream() method which would avoid the need to save it locally before sending to S3.


On Sat, Mar 1, 2014 at 3:23 PM, Heather and Jon Turgeon <[hidden email]> wrote:
Hello all, I am trying to use Stripes in an app that will be hosted on Amazon's AWS. I want to allow file upload and am running into a bit of a problem. Amazon wants me to store the file on S3 passing a byte array. It seems easy enough to do this if I were to have access to the File object in the FileBean, but it is private. So, any thoughts as the the easiest way to gain access to it while in the temp directory? I am trying to minimize the changes I would need to make to the framework. Thanks

Jon

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: File access in the FileBean

Rusty Wright-2
In reply to this post by Heather and Jon Turgeon
If you need a MultipartWrapper here's one by Moritz Petersen I got off the net a few years ago for Google App Engine (GAE).  With GAE you can't write to the local filesystem, writes are restricted to the database.  Adjust the code as necessary.




On Sat, Mar 1, 2014 at 12:23 PM, Heather and Jon Turgeon <[hidden email]> wrote:
Hello all, I am trying to use Stripes in an app that will be hosted on Amazon's AWS. I want to allow file upload and am running into a bit of a problem. Amazon wants me to store the file on S3 passing a byte array. It seems easy enough to do this if I were to have access to the File object in the FileBean, but it is private. So, any thoughts as the the easiest way to gain access to it while in the temp directory? I am trying to minimize the changes I would need to make to the framework. Thanks

Jon

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: File access in the FileBean

Rusty Wright-2
Sorry, I pasted the wrong one.  Refresh that pastebin page if you grabbed it before now.


On Sat, Mar 1, 2014 at 1:17 PM, Rusty Wright <[hidden email]> wrote:
If you need a MultipartWrapper here's one by Moritz Petersen I got off the net a few years ago for Google App Engine (GAE).  With GAE you can't write to the local filesystem, writes are restricted to the database.  Adjust the code as necessary.




On Sat, Mar 1, 2014 at 12:23 PM, Heather and Jon Turgeon <[hidden email]> wrote:
Hello all, I am trying to use Stripes in an app that will be hosted on Amazon's AWS. I want to allow file upload and am running into a bit of a problem. Amazon wants me to store the file on S3 passing a byte array. It seems easy enough to do this if I were to have access to the File object in the FileBean, but it is private. So, any thoughts as the the easiest way to gain access to it while in the temp directory? I am trying to minimize the changes I would need to make to the framework. Thanks

Jon

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users




------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: File access in the FileBean

Reuven Gaisin
You can create a byte array from the InputStream.  Get an InputStream from the FileBean and pass that into IOUtils.toByteArray(). IOUtils class is part of the Apache Commons IO library:

JavaDoc for IOUtils method:  http://commons.apache.org/proper/commons-io/javadocs/api-release/org/apache/commons/io/IOUtils.html#toByteArray%28java.io.InputStream%29

Also, remember to call delete() on the FileBean when you are done since you are streaming (see http://www.stripesframework.org/display/stripes/File+Uploads#FileUploads-ReadingtheuploadedfileasaStream ).

Reuven



On Sat, Mar 1, 2014 at 4:22 PM, Rusty Wright <[hidden email]> wrote:
Sorry, I pasted the wrong one.  Refresh that pastebin page if you grabbed it before now.


On Sat, Mar 1, 2014 at 1:17 PM, Rusty Wright <[hidden email]> wrote:
If you need a MultipartWrapper here's one by Moritz Petersen I got off the net a few years ago for Google App Engine (GAE).  With GAE you can't write to the local filesystem, writes are restricted to the database.  Adjust the code as necessary.




On Sat, Mar 1, 2014 at 12:23 PM, Heather and Jon Turgeon <[hidden email]> wrote:
Hello all, I am trying to use Stripes in an app that will be hosted on Amazon's AWS. I want to allow file upload and am running into a bit of a problem. Amazon wants me to store the file on S3 passing a byte array. It seems easy enough to do this if I were to have access to the File object in the FileBean, but it is private. So, any thoughts as the the easiest way to gain access to it while in the temp directory? I am trying to minimize the changes I would need to make to the framework. Thanks

Jon

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users




------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users