Hi, The httpClientLib doesn’t return body or bodyStream if the contentType is not text. So how do I get stream for image, is there something that I need to send as part of the request?
Hi, I just tested the code from the link above to fetch the image and save it as content. Everything worked perfectly fine without any extra parameters. See the code below. Can you post yours?
var httpClientLib = require('/lib/http-client');
var response = httpClientLib.request({
url: 'https://enonic.com/_/image/ce090bca-c09d-414c-ab57-0721b771e548:3f844b5a7cde4161dac57cc5e80633eccd1018d7/full/pwa.png',
method: 'GET'
});
var responseStream = response.bodyStream;
var mediaResult = contentLib.createMedia({
name: 'myImage',
parentPath: '/',
mimeType: 'image/png',
data: responseStream
});