If I understand your problem correctly, you want a redirect to convey 
information about the file being redirected to. AFAIK that’s not possible, 
you’ve directed the user towards a totally separate URL with it’s own headers 
(including mime type).

If you can’t control the headers of the actual file to be downloaded, a 
workaround might be to make your app read the files from the final location and 
serve the data yourself (as you mention). If you do it through a stream, it 
shouldn’t incur a large cost in terms of memory or CPU. And you’ll have full 
control over your headers.

Cheers,
- hugi



> On 9. okt. 2016, at 19:24, o...@ocs.cz wrote:
> 
> Hello there,
> 
> at the moment, my application can return a file to the user through
> 
> ===
>    WOResponse downloadFile(String mimeType, File path) {
>        WOResponse wor=new WOResponse()
>        wor.setHeader("$mimeType; name=\"$path.name\"","content-type")
>        wor.setContent(path.getText("utf-8"))
>        wor.disableClientCaching()
>        wor.removeHeadersForKey("Cache-Control")
>        wor.removeHeadersForKey("cache-control")
>        wor.removeHeadersForKey("pragma")
>        wor
>    }
> ===
> 
> The 'path' though happens to map to an URL, accessible directly through the 
> HTTP server (without a need to go through the application at all). Therefore, 
> I would like to replace the code above by something like
> 
> ===
>    WORedirect downloadFile(String mimeType, File path) {
>        WORedirect wor=new WORedirect(context())
>        wor.setUrl(URLForFile(path))
>        wor
>    }
> ===
> 
> to save, especially for bigger files, the memory and CPU. Nevertheless, I 
> can't see any way how to set the MIME type; is there any trick to do that?
> 
> Thanks,
> OC
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/hugi%40karlmenn.is
> 
> This email sent to h...@karlmenn.is


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to