File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -102,9 +102,10 @@ storeFileWithOptions fileInfo options = do
102
102
let destPath :: Text = " static/" <> objectPath
103
103
Directory. createDirectoryIfMissing True (cs $ " static/" <> directory)
104
104
105
- fileInfo
106
- |> get # fileContent
107
- |> LBS. writeFile (cs destPath)
105
+ trySaveFile <- Exception. try $ fileInfo |> get # fileContent |> LBS. writeFile (cs destPath)
106
+ case trySaveFile of
107
+ Left (Exception. SomeException e) -> throw e
108
+ Right _ -> pure ()
108
109
109
110
let frameworkConfig = getFrameworkConfig ? context
110
111
pure $ (get # baseUrl frameworkConfig) <> " /" <> objectPath
@@ -115,15 +116,18 @@ storeFileWithOptions fileInfo options = do
115
116
116
117
let contentType = cs (Wai. fileContentType fileInfo)
117
118
contentDisposition <- (get # contentDisposition options) fileInfo
118
- runMinio connectInfo do
119
+ trySaveFile <- runMinio connectInfo do
119
120
let options :: PutObjectOptions = defaultPutObjectOptions { pooContentType = Just contentType, pooContentDisposition = contentDisposition }
120
121
putObject bucket objectPath payload Nothing options
122
+ case trySaveFile of
123
+ Left e -> throw e
124
+ Right _ -> pure ()
121
125
122
126
pure $ baseUrl <> objectPath
123
127
124
128
pure StoredFile { path = objectPath, url }
125
129
126
- -- | Fetchs an url and uploads it to the storage.
130
+ -- | Fetches an url and uploads it to the storage.
127
131
--
128
132
-- The stored file has the content type provided by @Content-Type@ header of the downloaded file.
129
133
--
You can’t perform that action at this time.
0 commit comments