Shell.fetch and Content-Disposition header

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Shell.fetch and Content-Disposition header

tsukit
In glu script, when I try to fetch the application content for deployment with this call

shell.fetch('http://somehost:28080/theapp/some/rest/path/1')

glu downloads the file and name it '1' instead of using the actual name provided by Content-Disposition header in the response.

How can I get glu to use the header so the downloaded file has the right filename?

Thanks,
Ed
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Shell.fetch and Content-Disposition header

frenchyan
Administrator
This is the method that guess the filename: https://github.com/pongasoft/utils-misc/blob/master/org.linkedin.util-groovy/src/main/groovy/org/linkedin/groovy/util/net/GroovyNetUtils.groovy#L103

At this stage (meaning without changing the code) you would have to replace it with your own to do what you want:

shell.fetch(url, guessMyOwnFilename(url))

private def guessMyOwnFilename(url) {
      def filename
      def connection = uri.toURL().openConnection()
      connection.connect()
      try
      {
        filename = connection.getHeaderField("Content-Disposition")
        // extract filename part...
      }
      finally
      {
        connection.disconnect()
      }

   // ...

}

I created a ticket to add this as a feature in glu: https://github.com/pongasoft/glu/issues/275 but in the meantime you would have to implement it yourself.

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Shell.fetch and Content-Disposition header

tsukit
Thanks Yan!
Loading...