From 6e0db34f22b5f604e20b610eb707a4c6b8f23d84 Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Sat, 5 Oct 2024 20:19:46 +0300 Subject: [PATCH] Adapt createTemporaryDownloadUrlFromPathWithExpiredAt --- IHP/FileStorage/ControllerFunctions.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IHP/FileStorage/ControllerFunctions.hs b/IHP/FileStorage/ControllerFunctions.hs index a0c75f80c..0c091a062 100644 --- a/IHP/FileStorage/ControllerFunctions.hs +++ b/IHP/FileStorage/ControllerFunctions.hs @@ -226,7 +226,13 @@ createTemporaryDownloadUrlFromPathWithExpiredAt validInSeconds objectPath = do case storage of StaticDirStorage -> do let frameworkConfig = ?context.frameworkConfig - let url = frameworkConfig.baseUrl <> "/" <> objectPath + let urlSchemes = ["http://", "https://"] + + let url = if any (`isPrefixOf` objectPath) urlSchemes + -- BC, before we saved only the relative path of a file, we saved the full URL. So use it as is. + then objectPath + -- We have the relative path, so add the baseUrl. + else frameworkConfig.baseUrl <> objectPath pure TemporaryDownloadUrl { url = cs url, expiredAt = publicUrlExpiredAt } S3Storage { connectInfo, bucket} -> do