-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement io.readClassResource
and io.readClassLoaderResource
#2733
Conversation
chunkSize: Int, | ||
classLoader: ClassLoader = getClass().getClassLoader() | ||
)(implicit F: Sync[F]): Stream[F, Byte] = | ||
Stream.eval(F.delay(Option(classLoader.getResourceAsStream(name)))).flatMap { |
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.
Maybe this should be blocking 🤔
It might be nice to do this in a way which can use BTW, we should also note that the resource path is absolute, not relative to a class. E.g., |
How would that work exactly? Do you mean use For the former, I'm not sure if that's possible, since the file is embedded in the jar right? Seems like |
Yeah okay, I forgot that there's no default |
Ohh, no I think I got you. Maybe this is possible, using |
Right, we'd have to call |
def readClassResource[F[_], C]( | ||
name: String, | ||
chunkSize: Int | ||
)(implicit F: Sync[F], ct: ClassTag[C]): Stream[F, Byte] = |
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.
H/t @Daenyth for the classtag trick.
io.readResource
io.readClassResource
and io.readClassLoaderResource
Addresses #2503.