Im currently working on a file upload that will store the files to my temp_folder w/c is located in VAADIN/themes. I already run out of ideas how to set the path that my upload will be stored inside my temp_folder. here’s the latest code I created.
Java’s own temp file mechanism?
If it really is a temp folder and you only read the file again from the code, then why not use ?
I don’t know how good a thing it is to write stuff into your project structure. The java temp or some servlet container folder might be more appropriate.
actually, the main purpose of this is to transfer the file via FileInputStream to store it to S3 bucket of Amazon since the Upload class does not provide FileInputStream, Im not sure if this is the best solution but I just want to try if it works so I could report it to my boss. then maybe I’ll just change the code later to a more suitable structure.
Yeah if that is the case then I definitely think that you should pass the Upload component’s stream into File.createTempFile and push that forward to S3. The other option is to take the outputstream out of Upload, convert it to a inputstream and pass it directly to S3. I’m not familiar with what the S3 API works with so can’t be more specific than that.
I could write the file in my local folder using outputstream, the moment I push it to S3 only the filename(0 kb) is being stored. Im using this
toolkit to upload files to S3 and it requires inputstream to pass to the object. I have no idea how to convert the upload into an inputstream, i’ve tried everything I could find but still failed.
And notice that the upload is only starting when receiveUpload() is called, so don’t start pushing it forward from there - the file will be empty just as you described. Rather use uploadSucceeded() for that, which is called after the upload has actually happened.
Book of Vaadin: Upload .
I try access the file when it upload however it fail in this line:
File file = new File(event.getFilename());
Because event.getFilename() is “informes del 1 de junio al 16 de julio.csv” and the real path of file is "“C:\Users\marlow25\AppData\Local\Temp\JUpload$tmp\informes_del_1_de_junio_al_16_de_julio.csv”
any idea???
@Override
public void uploadSucceeded(SucceededEvent event) {
// TODO Auto-generated method stub
pi.setVisible(false);
upload.setVisible(true);
try {
File fileJMiner = new File(event.getFilename());
br = new BufferedReader(new FileReader(fileJMiner));
thank you
Hi,
but i dont want to upload a file to temperary location and from there to s3. It is taking more time because it looks like uploading two time. First to server temp location and from there to s3.
According to my concern it is not correct and not good.
Any idea, to upload file from client system to s3 direclty.
You can use PipedInputStream. In my (following) example I upload a file from user computer to another server (webdav), but the idea with S3 should be the same; just use methods you need.
Srikanth Shanigaram: Hi,
but i dont want to upload a file to temperary location and from there to s3. It is taking more time because it looks like uploading two time. First to server temp location and from there to s3.
According to my concern it is not correct and not good.
Any idea, to upload file from client system to s3 direclty.
Thanks.
You can use PipedInputStream. In my (following) example I upload a file from user computer to another server (webdav), but the idea with S3 should be the same; just use methods you need.