https://kotlinlang.org logo
#ktor
Title
# ktor
a

Alexander Suraphel

01/20/2022, 10:40 AM
What is the difference between
files
and resources ? StackOverflow question
✔️ 1
b

Big Chungus

01/20/2022, 11:38 AM
files()
looks at your file system relative to current working directory
resources()
looks at your classpath
🙏 1
a

Alexander Suraphel

01/20/2022, 11:39 AM
Got it now. Thanks 🙏 . No idea why I got downvoted on SO 😕
b

Big Chungus

01/20/2022, 11:43 AM
Because this quote is misleading
The
resources
method does the same as the
files
method except that it allows serving all static files from the source set resource directory that could be embedded in a JAR.
a

Alexander Suraphel

01/20/2022, 11:44 AM
Yeah. But was there an issue in my question on StackOverflow?
b

Big Chungus

01/20/2022, 11:44 AM
Oh that? No idea 😄
I’m confused too 🙂 i thought you were the one who answered it lol
b

Big Chungus

01/20/2022, 11:44 AM
Nah
a

Aleksei Tirman [JB]

01/20/2022, 11:52 AM
@Big Chungus could you please explain why it's misleading?
a

Alexander Suraphel

01/20/2022, 11:53 AM
@Aleksei Tirman [JB] i thought he was actually talking about the documentation. Your answer is clear to me.
b

Big Chungus

01/20/2022, 11:54 AM
For a newbie reading it at face value, it implies that resources only looks at the files you place in the
src/main/resources
(i.e. same as
files()
, but working on a different working directory), which is not the case and you can also use
resources()
to serve files on your classpath comming from other jars too.
that's why I said misleading, not wrong 🙂
a

Aleksei Tirman [JB]

01/20/2022, 12:01 PM
Is it better?
The 
resources
 method does the same as the 
files
 method except that it allows serving static files from the classpath.
b

Big Chungus

01/20/2022, 12:01 PM
It is for me, but who am I to say what's right or wrong with these things?
a

Aleksei Tirman [JB]

01/20/2022, 12:02 PM
I mean is it more precise?
b

Big Chungus

01/20/2022, 12:02 PM
Oh, yes it is.
a

Aleksei Tirman [JB]

01/20/2022, 12:08 PM
I've edited my answer.
🙏 2
b

Big Chungus

01/20/2022, 12:09 PM
Hope you don't take it the wrong way. I wasn't trying to pick on you or anything, just wanted it to be clear for everyone 😄
a

Aleksei Tirman [JB]

01/20/2022, 12:24 PM
Of course, I didn't 😄 It actually doesn't matter if you tried or not because you provided useful information nonetheless.
4 Views