[web-devel] [ANNOUNCE] First release of crypto-conduit

Michael Snoyman michael at snoyman.com
Sun Jan 8 14:05:34 CET 2012


On Sun, Jan 8, 2012 at 2:39 AM, Felipe Almeida Lessa
<felipe.lessa at gmail.com> wrote:
> On Sat, Jan 7, 2012 at 10:04 PM, Grant <thelff at hotmail.com> wrote:
>> Thanks for getting back to me so fast!  Actually, I need to include a string
>> with the file length plus the file stream itself and THEN hash that whole thing
>> together. The example below works, but the file is processed twice.
>>
>> Alternatively, I could create a specialised Source that gets the file size from
>> the handle and then processes the file but that looks ugly. Any ideas?
>
> I think we need the following:
>
>  openFile :: ResourceIO m :: FilePath -> ResourceT m Handle
>  sourceHandle :: ResourceIO m => Handle -> Source m B.ByteString
>
> So you would do something like
>
>  runResourceT $ do
>    handle <- CB.openFile fp
>    fileSize <- liftIO $ hFileSize handle
>    let source = CL.sourceList [encodeFileSize fileSize]
>                 `mappend` CB.sourceHandle handle
>    source $$ sinkHash
>
> Cheers!
>
> --
> Felipe.
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel

I've added openFile, sourceHandle and sinkHandle on Git[1]. Grant:
does that give you enough to solve the issues you were facing?

Michael

[1] https://github.com/snoyberg/conduit/blob/master/conduit/Data/Conduit/Binary.hs



More information about the web-devel mailing list