It's definitely a time saver and eficiency booster to be able to retrieve files from the internet directly from DOpus, thanks to the new HttpRequest object.
However, when the response is an Image object, is there a way to quickly convert it to a Blob for saving into disk, using File.Write()?
In the video above I'm using the clipboard to do that, which may not be ideal.
I did try using HtttpReq.ReadResponseData(), and not sure why, in this specific scenario, when I attempt to use it, the script freeze for about 10 seconds and I end up with a zero size blob after that.
If there's currently no way to achieve this, perhaps introducing a new method like Image.toBlob() could certainly help.
Last night I was playing around with it a bit further. It definitively seems to be something related to their API. If I use a workaround to explicit set the content type as an individual header (using PostData(key,value,content-type), content-type gets ignored in this case), I can read the response with ReadResponseData() as a blob with a valid size and no delay.
But...then another problem appears, which brings us back to the initial question.
I can't know if the response obtained is a valid image or not, until I save it to disk and verify it, which is not ideal either. (For example, if I receive an image I'm not satisfied with, I want to discard it and request another one with different parameters, instead of being forced to save it to view it, then discarded it.) That's why it seems to me that having a way to convert an Image object to a blob sound better.
Anyway, I suppose using the clipboard is a lesser evil.