Permalink
Browse files

Merge remote branch 'origin/i0066'

  • Loading branch information...
2 parents 6579f53 + 75a8ebf commit 443a83b9c1a86ebe4a2c2cc667013f0b8f7d0902 Katsutoshi Itoh committed Jan 25, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 Handler/S3.hs
View
@@ -33,14 +33,14 @@ getUploadR = do
addWidget $(widgetFile "s3/upload")
upload uid fi = do
- if fileName fi /= "" && L.length (fileContent fi) > 0
+ if fileName' fi /= "" && L.length (fileContent fi) > 0
then do
now <- liftIO getCurrentTime
- let (name, ext) = splitExtension $ T.unpack $ fileName fi
- efname = encodeUrl $ fileName fi
+ let (name, ext) = splitExtension $ T.unpack $ fileName' fi
+ efname = encodeUrl $ fileName' fi
fsize = L.length $ fileContent fi
fid <-
- insert FileHeader { fileHeaderFullname=fileName fi
+ insert FileHeader { fileHeaderFullname=fileName' fi
, fileHeaderEfname=efname
, fileHeaderContentType=fileContentType fi
, fileHeaderFileSize=fsize
@@ -54,8 +54,11 @@ upload uid fi = do
liftIO $ do
createDirectoryIfMissing True s3dir
L.writeFile s3fp (fileContent fi)
- return $ Just (fid, fileName fi, T.pack ext, fsize, now)
+ return $ Just (fid, fileName' fi, T.pack ext, fsize, now)
else return Nothing
+ where
+ fileName' :: FileInfo -> T.Text
+ fileName' = last . T.split (\c -> c=='/' || c=='\\') . fileName
postUploadR :: Handler RepXml
postUploadR = do

0 comments on commit 443a83b

Please sign in to comment.