Please remove me from your mailing List

Thanks
Jenny Ramos
Tape Operator
Secaucus, NJ
201-392-6205




From:   Raymond Feng <[email protected]>
To:     [email protected], 
Date:   09/07/2012 01:27 PM
Subject:        Re: How to determine completion of file download request.



Did you call the delete after super.close()?

On Sep 7, 2012, at 7:39 AM, Rohit wrote:

Thank You for the response.

I tried extending FileInputStream and overriding the close method.

The code works properly. close is being called. The delete API calls works 
and return true.

However,

The file is not deleted.


Apologies for using incorrect English in previous email.

Also, for future users. the code here is a test code. Do not use as is. 
This will cause your app to serve any file which the process has read 
permission.

 
 
Sent to you by Rohit via Google Reader:
 
 
Re: How to determine completion of file download request.
via [email protected] Archives by Raymond Feng <
[email protected]> on 9/1/12

You can subclass FileInputStream to override the close() method so that 
you can be notified
when the close() is called.

Thanks,
Raymond

On Sep 1, 2012, at 8:47 AM, Rohit Singh wrote:

> Hello,
> 
> I am implement a API that lets user download file.
> 
> This file is created for each user and can be different for each 
request.
> 
> So, I have to delete the file when a user is done downloading the file. 
The files size
can be in Gigs, so the download wont be quick.
> 
> We are using wink for rest of the API, this is just a extension. So I 
will not like to
keep implementation as is in same file.
> 
> My question is how do I know that the download operation is finished, so 
I can delete
the file.
> 
> 
> Here is a test case, similar to what I do in the real implementation.
> 
> 
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.io.FileReader;
> import java.io.IOException;
> import java.io.LineNumberReader;
> import java.io.FileInputStream;
> import java.io.InputStream;
> import javax.ws.rs.GET;
> import javax.ws.rs.HeaderParam;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.Context;
> import javax.ws.rs.core.HttpHeaders;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
> import javax.ws.rs.core.Response.ResponseBuilder;
> 
> @Path("fileDownLoader")
> public class FileDownLoader {
>                private final String logpath = "C:\\temp\\";
> 
>                @Context
>                HttpHeaders requestHeaders;
> 
>                @GET
>                @Produces({"application/json"})
>                @Path("/{fileName}")
>                public Response downLoadFile(@PathParam("fileName") 
String fileName) {
> 
>         Response response = null;
>                                InputStream in = null;
>                                try {
>                                in = new 
FileInputStream(logpath+fileName);
>                                response = Response.ok(in, 
MediaType.APPLICATION_OCTET_STREAM_TYPE).build();
>                                } catch( FileNotFoundException fnfe) {
>                        fnfe.printStackTrace();
>                                }
> 
>                                return response;
> 
>   }
> }
> 
> -- 
> -- 
> Rohit
> 
> “We all die. The goal isn't to live forever, the goal is to create 
something that will.”
Chuck Palahniuk
> 
> http://www.facebook.com/huskercane
> 





 
 
Things you can do from here:
Subscribe to [email protected] Archives using Google Reader
Get started using Google Reader to easily keep up with all your favorite 
sites
 
 


Reply via email to