yesod-s3 (empty) → 0.1.0.0
raw patch · 4 files changed
+82/−0 lines, 4 filesdep +basedep +bytestringdep +conduitsetup-changed
Dependencies added: base, bytestring, conduit, hS3, network, text, yesod-core
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- Yesod/S3.hs +33/−0
- yesod-s3.cabal +27/−0
+ LICENSE view
@@ -0,0 +1,20 @@+The MIT License (MIT)++Copyright (c) 2013 Timo von Holtz++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of+the Software, and to permit persons to whom the Software is furnished to do so,+subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Yesod/S3.hs view
@@ -0,0 +1,33 @@+module Yesod.S3 where++import Data.ByteString.Lazy+import Yesod.Core.Types+import Data.Conduit+import Data.Conduit.Binary+import Network.URI+import Network.AWS.AWSConnection+import Network.AWS.AWSResult+import Network.AWS.S3Object+import qualified Data.Text as T++extractFile :: FileInfo -> IO ByteString+extractFile f = runResourceT $ fileSourceRaw f $$ sinkLbs++uploadFile :: AWSConnection+ -> FileInfo+ -> String -- ^ The Bucket Name+ -> String -- ^ The Object Name+ -> IO (AWSResult ())+uploadFile conn fi bucket name = do+ bs <- extractFile fi+ let obj = S3Object bucket name (T.unpack $ fileContentType fi) [] bs+ sendObjectMIC conn obj++getLink :: AWSConnection+ -> String -- ^ The Bucket Name+ -> String -- ^ The Object Name+ -> Integer -- ^ Seconds the Link should be valid+ -> IO URI -- ^ IO is only used to get the current Time+getLink conn bucket name t = do+ let obj = S3Object bucket name "" [] empty+ publicUriForSeconds conn obj t
+ yesod-s3.cabal view
@@ -0,0 +1,27 @@+name: yesod-s3+version: 0.1.0.0+synopsis: Simple Helper Library for using Amazon's Simple Storage Service (S3) with Yesod+-- description: +homepage: https://github.com/tvh/yesod-s3+bug-reports: http://github.com/tvh/yesod-s3/issues+license: MIT+license-file: LICENSE+author: Timo von Holtz+maintainer: tvh@tvholtz.de+copyright: Copyright (C) 2013 Timo von Holtz+category: Yesod+build-type: Simple+cabal-version: >=1.8++library+ exposed-modules:+ Yesod.S3+ -- other-modules: + build-depends:+ base ==4.*,+ hS3,+ yesod-core,+ bytestring,+ text,+ conduit >= 1.0.5,+ network