Temp file upload changes in wai-extra 2.0.1 #630
This commit is contained in:
parent
d8bdcae2d5
commit
d4998d2246
@ -152,7 +152,7 @@ import Control.Monad (liftM)
|
|||||||
import qualified Control.Monad.Trans.Writer as Writer
|
import qualified Control.Monad.Trans.Writer as Writer
|
||||||
|
|
||||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||||
import Control.Monad.Trans.Resource (MonadResource, liftResourceT)
|
import Control.Monad.Trans.Resource (MonadResource, liftResourceT, InternalState)
|
||||||
|
|
||||||
import qualified Network.HTTP.Types as H
|
import qualified Network.HTTP.Types as H
|
||||||
import qualified Network.Wai as W
|
import qualified Network.Wai as W
|
||||||
@ -183,7 +183,7 @@ import Yesod.Core.Content (ToTypedContent (..), simpleConte
|
|||||||
import Yesod.Core.Internal.Util (formatRFC1123)
|
import Yesod.Core.Internal.Util (formatRFC1123)
|
||||||
import Text.Blaze.Html (preEscapedToMarkup, toHtml)
|
import Text.Blaze.Html (preEscapedToMarkup, toHtml)
|
||||||
|
|
||||||
import Control.Monad.Trans.Resource (ResourceT, runResourceT, withInternalState)
|
import Control.Monad.Trans.Resource (ResourceT, runResourceT, withInternalState, getInternalState, liftResourceT)
|
||||||
import Data.Dynamic (fromDynamic, toDyn)
|
import Data.Dynamic (fromDynamic, toDyn)
|
||||||
import qualified Data.IORef.Lifted as I
|
import qualified Data.IORef.Lifted as I
|
||||||
import Data.Maybe (listToMaybe)
|
import Data.Maybe (listToMaybe)
|
||||||
@ -233,7 +233,10 @@ runRequestBody = do
|
|||||||
Just rbc -> return rbc
|
Just rbc -> return rbc
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
rr <- waiRequest
|
rr <- waiRequest
|
||||||
#if MIN_VERSION_wai(2, 0, 0)
|
#if MIN_VERSION_wai_extra(2, 0, 1)
|
||||||
|
internalState <- liftResourceT getInternalState
|
||||||
|
rbc <- liftIO $ rbHelper upload rr internalState
|
||||||
|
#elif MIN_VERSION_wai(2, 0, 0)
|
||||||
rbc <- liftIO $ rbHelper upload rr
|
rbc <- liftIO $ rbHelper upload rr
|
||||||
#else
|
#else
|
||||||
rbc <- liftResourceT $ rbHelper upload rr
|
rbc <- liftResourceT $ rbHelper upload rr
|
||||||
@ -242,15 +245,20 @@ runRequestBody = do
|
|||||||
return rbc
|
return rbc
|
||||||
|
|
||||||
#if MIN_VERSION_wai(2, 0, 0)
|
#if MIN_VERSION_wai(2, 0, 0)
|
||||||
rbHelper :: FileUpload -> W.Request -> IO RequestBodyContents
|
rbHelper :: FileUpload -> W.Request -> InternalState -> IO RequestBodyContents
|
||||||
|
rbHelper upload req internalState =
|
||||||
#else
|
#else
|
||||||
rbHelper :: FileUpload -> W.Request -> ResourceT IO RequestBodyContents
|
rbHelper :: FileUpload -> W.Request -> ResourceT IO RequestBodyContents
|
||||||
|
rbHelper upload req =
|
||||||
#endif
|
#endif
|
||||||
rbHelper upload =
|
|
||||||
case upload of
|
case upload of
|
||||||
FileUploadMemory s -> rbHelper' s mkFileInfoLBS
|
FileUploadMemory s -> rbHelper' s mkFileInfoLBS req
|
||||||
FileUploadDisk s -> rbHelper' s mkFileInfoFile
|
#if MIN_VERSION_wai_extra(2, 0, 1)
|
||||||
FileUploadSource s -> rbHelper' s mkFileInfoSource
|
FileUploadDisk s -> rbHelper' (s internalState) mkFileInfoFile req
|
||||||
|
#else
|
||||||
|
FileUploadDisk s -> rbHelper' s mkFileInfoFile req
|
||||||
|
#endif
|
||||||
|
FileUploadSource s -> rbHelper' s mkFileInfoSource req
|
||||||
|
|
||||||
rbHelper' :: NWP.BackEnd x
|
rbHelper' :: NWP.BackEnd x
|
||||||
-> (Text -> Text -> x -> FileInfo)
|
-> (Text -> Text -> x -> FileInfo)
|
||||||
|
|||||||
@ -134,7 +134,11 @@ data FileInfo = FileInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
data FileUpload = FileUploadMemory !(NWP.BackEnd L.ByteString)
|
data FileUpload = FileUploadMemory !(NWP.BackEnd L.ByteString)
|
||||||
|
#if MIN_VERSION_wai_extra(2, 0, 1)
|
||||||
|
| FileUploadDisk !(InternalState -> NWP.BackEnd FilePath)
|
||||||
|
#else
|
||||||
| FileUploadDisk !(NWP.BackEnd FilePath)
|
| FileUploadDisk !(NWP.BackEnd FilePath)
|
||||||
|
#endif
|
||||||
| FileUploadSource !(NWP.BackEnd (Source (ResourceT IO) ByteString))
|
| FileUploadSource !(NWP.BackEnd (Source (ResourceT IO) ByteString))
|
||||||
|
|
||||||
-- | How to determine the root of the application for constructing URLs.
|
-- | How to determine the root of the application for constructing URLs.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.2.6.1
|
version: 1.2.6.2
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user