haskell - Yesod - Should user profile pictures be stored in the static directory? -


currently profile pictures users upload saved /static/avatars/{upload-date}. generate staticr route image via information stored in database (they added @ runtime staticr route doesn't exist).

the problem i've run when user updates profile picture still old 1 due caching of static files. there way around or should storing images somewhere else? if how go accessing images /avatars/{upload-date}/{userid}.png?

i know create route along lines of /avatars/#day/#userid i'm not sure how ".png" or ".jpg" appended that. or write handler function.

i know create route along lines of /avatars/#day/#userid i'm not sure how ".png" or ".jpg" appended th

there no need url should end png or jpeg extension. need make sure content type header set properly.

or write handler function.

that's quite simple. if serving png images, have use functions sendfile , typepng serve them:

myavatarhandler = sendfile typepng "/home/yesod/static/avatars/day/userid.png" 

also in example, make sure store timestamp of upload , change url according that. or else 2 profile images updated in same day cached.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -