Re: [Resteasy-users] @Produces with application/octect-stream and filename

2012-01-18 Thread Akram
Hi all
I worked around it by adding the response as an argument of my method and 
adding the required header to the response
The interceptor solution is more elegant but I did not manage to make it work 
since I can't find a way to pass the file name to the interceptor


Sent from mobile

On 17 janv. 2012, at 23:59, Bill Burke  wrote:

> It looks like it takes it from the last segment of the path you queried.  
> You'll have to play around with it.
> 
> On 1/17/12 5:54 PM, Akram wrote:
>> Hi Bill,
>> 
>> my code is working fine except that I got the following screenshot when
>> accessing:
>> http://localhost:8080/resources/repository/default/items/myfile/download
>> 
>> 
>> 
>> Where I want firefox to propose me "myfile" instead of "download".
>> 
>> 
>> Le 17/01/12 23:51, Bill Burke a écrit :
>>> Not sure how file download works.  File upload uses multipart though.
>>> Maybe the same for download?
>>> 
>>> On 1/17/12 5:47 PM, Akram wrote:
 Hi Resteasy players,
 
 I just wrote a JAX-RS Webservice that produces application/octet-stream
 flow to allow download of a file.
 When I access the service through firefox, I would like that the Save as
 dialog box proposes the name of the file as the default filename.
 
 Any idea on how to do this with RestEasy ?
 Here is my code snippet:
 
  @GET
  @Path("/{repositoryName}/{workspaceName}/items{path:.*}/download")
  @Produces("application/octet-stream")
  public InputStream getItem(@Context HttpServletRequest request,
  @PathParam("repositoryName") String rawRepositoryName,
 @PathParam("workspaceName") String rawWorkspaceName,
  @PathParam("path") String path) throws JSONException,
 UnauthorizedException, RepositoryException {
 
  Repository repository =
 RepositoryUtils.getRepository(rawRepositoryName);
  Session session = repository.login(rawWorkspaceName);
  Node fileNode = session.getNode(path);
 
  Node jcrContent = fileNode.getNode("jcr:content");
  String fileName = fileNode.getName();
  logger.info("Downloading file {}", fileName);
  return jcrContent.getProperty("jcr:data").getBinary().getStream();
  }
 
 
 Greetings
 Akram
 
 
 --
 Keep Your Developer Skills Current with LearnDevNow!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-d2d
 ___
 Resteasy-users mailing list
 Resteasy-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/resteasy-users
>> 
> 
> -- 
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
> 


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] @Produces with application/octect-stream and filename

2012-01-17 Thread Bill Burke
Not sure how file download works.  File upload uses multipart though. 
Maybe the same for download?

On 1/17/12 5:47 PM, Akram wrote:
> Hi Resteasy players,
>
> I just wrote a JAX-RS Webservice that produces application/octet-stream
> flow to allow download of a file.
> When I access the service through firefox, I would like that the Save as
> dialog box proposes the name of the file as the default filename.
>
> Any idea on how to do this with RestEasy ?
> Here is my code snippet:
>
>   @GET
>   @Path("/{repositoryName}/{workspaceName}/items{path:.*}/download")
>   @Produces("application/octet-stream")
>   public InputStream getItem(@Context HttpServletRequest request,
>   @PathParam("repositoryName") String rawRepositoryName,
> @PathParam("workspaceName") String rawWorkspaceName,
>   @PathParam("path") String path) throws JSONException,
> UnauthorizedException, RepositoryException {
>
>   Repository repository =
> RepositoryUtils.getRepository(rawRepositoryName);
>   Session session = repository.login(rawWorkspaceName);
>   Node fileNode = session.getNode(path);
>
>   Node jcrContent = fileNode.getNode("jcr:content");
>   String fileName = fileNode.getName();
>   logger.info("Downloading file {}", fileName);
>   return jcrContent.getProperty("jcr:data").getBinary().getStream();
>   }
>
>
> Greetings
> Akram
>
>
> --
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users