<p dir="auto"><strong>Glide Version</strong>: 4.3.1</p>

<p dir="auto"><strong>Integration libraries</strong>: None</p>

<p dir="auto"><strong>Device/Android Version</strong>: LG G4, 6.1</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>:<br>
Previously in Glide v3.7.0 the signature of the <code class="notranslate">encode</code> method in <code class="notranslate">Encoder</code> interface was:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="boolean encode(T data, OutputStream os)"><pre class="notranslate"><span class="pl-smi">boolean</span> <span class="pl-s1">encode</span>(<span class="pl-smi">T</span> <span class="pl-s1">data</span>, <span class="pl-smi">OutputStream</span> <span class="pl-s1">os</span>)</pre></div>
<p dir="auto">And in Glide v4.X it became:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public boolean encode(InputStream data, File file, Options options)"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-s1">encode</span>(<span class="pl-smi">InputStream</span> <span class="pl-s1">data</span>, <span class="pl-smi">File</span> <span class="pl-s1">file</span>, <span class="pl-smi">Options</span> <span class="pl-s1">options</span>)</pre></div>
<p dir="auto">I understand that mostly, encoders will use <code class="notranslate">File</code> as a parameter that will be used for the encoding, but there's an exception when it comes to encryption encoding:<br>
For instance, Conceal library uses cipher <code class="notranslate">OutputStream</code>s to write encrypted data.<br>
In Glide v3.X My custom Encoder has created a ciphered <code class="notranslate">OutputStream</code> and then use the built-in <code class="notranslate">BitmapEncoder</code> to do the encoding work with the ciphered <code class="notranslate">OutputStream</code> it generated,<br>
In Glide v4.X, <code class="notranslate">BitmapEncoder</code> accepts a <code class="notranslate">File</code> and not <code class="notranslate">OutputStream</code> as before, so my encoder cannot make use of the <code class="notranslate">BitmapEncoder</code> class to do the encoding work unfortunately, which means that my custom <code class="notranslate">Encoder</code> has to be responsible for the encryption + encoding process by itself, instead of just the encryption like in Glide v3.X.</p>
<p dir="auto">I think that <code class="notranslate">Encoder</code> interface should accept also <code class="notranslate">OutputStream</code> and not just <code class="notranslate">File</code> objects to handle these kind of situations.</p>
<p dir="auto">Here's an example usage in Glide 3.X:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="OutputStream outputStream = crypto.getCipherOutputStream(new BufferedOutputStream(os), Entity.create(&quot;cache_entity&quot;));
            encoded =  new BitmapEncoder().encode(data, outputStream);"><pre class="notranslate"><span class="pl-smi">OutputStream</span> <span class="pl-s1">outputStream</span> = <span class="pl-s1">crypto</span>.<span class="pl-en">getCipherOutputStream</span>(<span class="pl-k">new</span> <span class="pl-smi">BufferedOutputStream</span>(<span class="pl-s1">os</span>), <span class="pl-smi">Entity</span>.<span class="pl-en">create</span>(<span class="pl-s">"cache_entity"</span>));
            <span class="pl-s1">encoded</span> =  <span class="pl-k">new</span> <span class="pl-smi">BitmapEncoder</span>().<span class="pl-en">encode</span>(<span class="pl-s1">data</span>, <span class="pl-s1">outputStream</span>);</pre></div>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Glide.with..."><pre class="notranslate"><span class="pl-smi">Glide</span>.<span class="pl-smi">with</span>...</pre></div>

<p dir="auto"><strong>Layout XML</strong>:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;FrameLayout xmlns:android=&quot;..."><pre class="notranslate">&lt;<span class="pl-ent">FrameLayout</span> <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>...</span></pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>:</p>
<div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="paste stack trace and/or log here"><pre class="notranslate"><span class="pl-en">paste</span> <span class="pl-en">stack</span> <span class="pl-en">trace</span> <span class="pl-k">and</span>/<span class="pl-en">or</span> <span class="pl-en">log</span> <span class="pl-en">here</span></pre></div>
<p dir="auto">My Project has encrypted files to get from diskcache, so use "DiskCache.get(Key key)", I can't read data from file.And I suggest we can change the return "File" with "InputStream".</p>