I have a workflow in which i programmatically generate a layer's SLD from the layer data at the same moment that I upload the layer. To keep things fast, neat & tidy I write the contents of my SLD to an io.BytesIO (in-memory file) rather than writing it to disk.
When I call Geoserver.Geoserver.upload_style, it explicitly expects a path-like string and tried to open said path (source). I cannot figure out a way to "trick" it into accepting my in-memory file, since the in-memory file is effectively an analog for what is returned from open().
I propose modifying this function to accept either a path-like string or an io.BytesIO object. With a very quick hack, I verified that the function will still work if you pass an io.BytesIO object by just skipping the file read step:
Are you sure that it will work like this without saving it the disk? If that's the case, please send the PR. I will also recheck the feature and merge it, if it work.
I have a workflow in which i programmatically generate a layer's SLD from the layer data at the same moment that I upload the layer. To keep things fast, neat & tidy I write the contents of my SLD to an
io.BytesIO
(in-memory file) rather than writing it to disk.When I call
Geoserver.Geoserver.upload_style
, it explicitly expects a path-like string and tried to open said path (source). I cannot figure out a way to "trick" it into accepting my in-memory file, since the in-memory file is effectively an analog for what is returned fromopen()
.I propose modifying this function to accept either a path-like string or an
io.BytesIO
object. With a very quick hack, I verified that the function will still work if you pass anio.BytesIO
object by just skipping the file read step:Thoughts on this? I guess we can check the object type at runtime and then make a call to
open()
only if it is a string.I can make PR for this if you agree.