-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save only the relative path of the filename for StaticDirStorage
#1990
Conversation
I still need to verify it locally, but looking here: ihp/IHP/FileStorage/ControllerFunctions.hs Lines 223 to 229 in a58f7a0
It looks like it's expecting |
let | ||
requestBody = FormBody { params = [], files = [] } | ||
request = Wai.defaultRequest | ||
requestContext = RequestContext { request, respond = error "respond", requestBody, frameworkConfig = error "frameworkConfig" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpscholten 👋 I suspect this line, with the error
, causes the error I get when running the test
How can I make it work? (Copied from here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That GHC error is unrelated to the error call. I just pushed a workaround via 66518de to master (appartently the INLINE triggers the bug in GHC, but chaging that to an optional inline via INLINABLE not triggers the bug). Can you sync with master and then check again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use IHP.FrameworkConfig.withFrameworkConfig
to get a framework config object, like this:
let withFrameworkConfig = IHP.FrameworkConfig.withFrameworkConfig (pure ())
describe "createTemporaryDownloadUrlFromPathWithExpiredAt" $ do
it "returns baseUrl concatenated with objectPath when objectPath does not start with http:// or https://" $ do
withFrameworkConfig \frameworkConfig -> do
context <- createControllerContext frameworkConfig
let ?context = context
let objectPath = "static/test.txt"
temporaryDownloadUrl <- createTemporaryDownloadUrlFromPath objectPath
temporaryDownloadUrl.url `shouldBe` "http://localhost:8000/static/test.txt"
And then use the frameworkConfig passed to createControllerContext
instead of the error
call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this I get
./IHP/Prelude.hs:92:17:
1) IHP.FileStorage.ControllerFunctions.storeFileWithOptions returns the objectPath without the baseUrl
uncaught exception: ErrorCall
Could not find FileStorage in config. Did you call initS3Storage from your Config.hs?
CallStack (from HasCallStack):
error, called at ./IHP/Prelude.hs:92:17 in main:IHP.Prelude
While trying to figure how to pass a config with the initStaticDirStorage
(didn't figure yet), I found aroundAll (withIHPApp WebApplication config) do
Maybe we should use that? (If so, not sure how 😅 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to init the storage here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests passing locally ✌️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks 👍
fixes #1989