1
我正在使用Guzzle 6並且在從REST端點獲取圖像數據時遇到問題。無法使用Guzzle強制原始圖像數據的內容類型
$client = new Client(['base_uri' => $base_uri]);
$type = 'POST'; //..or 'GET'...doesn't make a difference
$url = //..the endpoint where the image is served from
$headers['Content-Type'] = 'text/xml; charset=x-user-defined';
$response = $client->request($type, $url, ['headers'=>$headers, 'decode_content' => false]);
我的要求,迫使MIME類型被忽略,返回的內容類型總是"image/jpeg"
,並且數據被改寫的,所以我不能簡單地把它粘成一個html標籤"<img src=... />"
。
謝謝...我終於意識到,我可以做任何我想要的數據從流中返回的數據;在這種情況下,如果我將它編碼到base64並在其前面放置正確的提示:'data:image/jpeg; base64,' - html'
'標記正常工作。 –
是的,那正確:) – Dekel