FileUploadSource (#262)
This commit is contained in:
parent
7efbab8846
commit
d38e9a8c0a
@ -343,6 +343,7 @@ rbHelper upload =
|
|||||||
case upload of
|
case upload of
|
||||||
FileUploadMemory s -> rbHelper' s mkFileInfoLBS
|
FileUploadMemory s -> rbHelper' s mkFileInfoLBS
|
||||||
FileUploadDisk s -> rbHelper' s mkFileInfoFile
|
FileUploadDisk s -> rbHelper' s mkFileInfoFile
|
||||||
|
FileUploadSource s -> rbHelper' s mkFileInfoSource
|
||||||
|
|
||||||
rbHelper' :: Sink S8.ByteString (ResourceT IO) x
|
rbHelper' :: Sink S8.ByteString (ResourceT IO) x
|
||||||
-> (Text -> Text -> x -> FileInfo)
|
-> (Text -> Text -> x -> FileInfo)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ module Yesod.Internal.Request
|
|||||||
, fileMove
|
, fileMove
|
||||||
, mkFileInfoLBS
|
, mkFileInfoLBS
|
||||||
, mkFileInfoFile
|
, mkFileInfoFile
|
||||||
|
, mkFileInfoSource
|
||||||
, FileUpload (..)
|
, FileUpload (..)
|
||||||
-- The below are exported for testing.
|
-- The below are exported for testing.
|
||||||
, randomString
|
, randomString
|
||||||
@ -141,5 +142,9 @@ mkFileInfoLBS name ct lbs = FileInfo name ct (sourceList $ L.toChunks lbs) (\fp
|
|||||||
mkFileInfoFile :: Text -> Text -> FilePath -> FileInfo
|
mkFileInfoFile :: Text -> Text -> FilePath -> FileInfo
|
||||||
mkFileInfoFile name ct fp = FileInfo name ct (sourceFile fp) (\dst -> runResourceT $ sourceFile fp $$ sinkFile dst)
|
mkFileInfoFile name ct fp = FileInfo name ct (sourceFile fp) (\dst -> runResourceT $ sourceFile fp $$ sinkFile dst)
|
||||||
|
|
||||||
|
mkFileInfoSource :: Text -> Text -> Source (ResourceT IO) ByteString -> FileInfo
|
||||||
|
mkFileInfoSource name ct src = FileInfo name ct src (\dst -> runResourceT $ src $$ sinkFile dst)
|
||||||
|
|
||||||
data FileUpload = FileUploadMemory (Sink ByteString (ResourceT IO) L.ByteString)
|
data FileUpload = FileUploadMemory (Sink ByteString (ResourceT IO) L.ByteString)
|
||||||
| FileUploadDisk (Sink ByteString (ResourceT IO) FilePath)
|
| FileUploadDisk (Sink ByteString (ResourceT IO) FilePath)
|
||||||
|
| FileUploadSource (Sink ByteString (ResourceT IO) (Source (ResourceT IO) ByteString))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user