B4J Question Trying to Downloading an image from Octoprint - how to resolve the URI

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Trying to grab an image from octoprint.
I have all the needed into it seems I need to combine the path

Help from the octoprint discord pointed me at this.
val imageUrl = "http://octopi:8080".toHttpUrl().newBuilder(file.thumbnail).build()

Tried a few things for the last hour or 2
I have all the needed info from the REST API call just cannot figure out how to combine them to a usable URL.

Anyway, just wonder if anyone could point me in a direction.

** FYI: I live in a city that is... Well the Internet is spotty at best (if it works at all) but that's another story for another place.
Forgive me if it takes a while for me to reply. **
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
have them even offline as I have MAJOR internet issues
I don´t know Octoprint at all.
As it is a software i thought the software implements a http-Server which you can use in your network (even with no internet). The rest-docs are always using example.com as address. This can probably be your IP in local network running the Octoprint-Software?

Find the documentation which describes retrieving thumbnails.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I believe I need to combine that with the octo base address "http://octopi:8080" or in my case "http://192.168.1.212:5005"
As the discord guys said...
val imageUrl = "http://octopi:8080".toHttpUrl().newBuilder(file.thumbnail).build()

So in my REST reply --- file.thumbnail is:
"plugin/prusaslicerthumbnails/thumbnail/Cooler_Master_HDD_Rails_v4TN.png?20220619044740"

Lots of JAVA help there on Discord, no B4J help... Most are using the the Picasa JAVA lib for rendering.

@DonManfred Octoprint is a local server running on a RasPi. The REST docs are pretty good, I have seen worse.
There is no direct example as thumbnails are an add-in provided by the 3d printer slicer software. So you slice a model and sent it to Octoprint.
Seems the Octo REST API just shares the info it has.

REST API returned record.
B4X:
{"date":1655603260,"display":"Cooler_Master_HDD_Rails_v4TN.gcode","gcodeAnalysis":{"dimensions":{"depth":180.0,"height":12.11,"width":150.775},"estimatedPrintTime":4388.363748692448,"filament":{"tool0":{"length":13097.13245999981,"volume":31.502295325811918}},"printingArea":{"maxX":150.775,"maxY":190.0,"maxZ":12.11,"minX":0.0,"minY":10.0,"minZ":0.0}},"hash":"7f0c9744aa65530f252cd9511a9845beb93d10f6","name":"Cooler_Master_HDD_Rails_v4TN.gcode","origin":"local","path":"Cooler_Master_HDD_Rails_v4TN.gcode","prints":{"failure":21,"last":{"date":1655808422.1516638,"success":false},"success":0},"refs":{"download":"http://192.168.1.236:5003/downloads/files/local/Cooler_Master_HDD_Rails_v4TN.gcode","resource":"http://192.168.1.236:5003/api/files/local/Cooler_Master_HDD_Rails_v4TN.gcode"},"size":3011198,"statistics":{"averagePrintTime":{},"lastPrintTime":{}},"thumbnail":"plugin/prusaslicerthumbnails/thumbnail/Cooler_Master_HDD_Rails_v4TN.png?20220619044740","thumbnail_src":"prusaslicerthumbnails","type":"machinecode","typePath":["machinecode","gcode"]}

And my BEST TOOL!!!!!!!!!!!!!!!!


 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
val imageUrl = "http://octopi:8080".toHttpUrl().newBuilder(file.thumbnail).build()

Got it figured all.
Just add "http://192.168.1.212:5005" and file.thumbnail var returned from Octoprint.
Just made sure it was all was clean and properly formatted.

The ".toHttpUrl().newBuilder(file.thumbnail).build()" JAVA code just threw me for a loop. Thought there was something special to be done.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…