You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Alexander Klimetschek <ak...@adobe.com> on 2015/03/25 02:49:09 UTC
resource.adaptTo(Reader.class)
Hi,
when reading text files (nt:files) via the resource API, it would be useful to be able to adapt to a Reader, that is set up with the right charset. Instead of having to resource.adaptTo(InputStream.class) and manually figuring out the charset.
The charset would be either jcr:encoding on the jcr:content [1], or default to the common utf-8 by default.
wdyt?
[1] http://wiki.apache.org/jackrabbit/nt%3Aresource
Cheers,
Alex
Re: resource.adaptTo(Reader.class)
Posted by Alexander Klimetschek <ak...@adobe.com>.
On 25.03.2015, at 01:26, Bertrand Delacretaz <bd...@apache.org> wrote:
> Sounds good to me but how do you define "text file" in this context?
>
> Mime type, filename, sniffing? A pluggable way of doing that would be best.
No need for detecting a text file, the application requests it with adaptTo(Reader.class), if that provides a broken stream because the binary is not a text file, then it's a problem of the application. Just a little utility helper here.
Cheers,
Alex
Re: resource.adaptTo(Reader.class)
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Mar 25, 2015 at 2:49 AM, Alexander Klimetschek
<ak...@adobe.com> wrote:
> ...when reading text files (nt:files) via the resource API, it would be useful
> to be able to adapt to a Reader, that is set up with the right charset....
Sounds good to me but how do you define "text file" in this context?
Mime type, filename, sniffing? A pluggable way of doing that would be best.
-Bertrand