尝试显示 Nuxeo 文档时返回不可读的内容
Unreadable content is returned when trying to show Nuxeo document
有一个API可以用来预览Nuxeo文档;是这样的:
http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image
它应该显示图像内容:
现在我在 file_get_contents
中调用它,但我得到了不可读的内容:
<?php
$opts = [
"http" => [
"method" => "GET",
"header" => array("Authorization: Basic " . base64_encode('Administrator:Administrator'),
"Content-type: image/jpg")
]
];
$context = stream_context_create($opts);
echo file_get_contents("http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image", false, $context);
?>
我尝试使用 gzdecode
但我得到 data error
异常,尽管 magic_quotes_runtime
不存在于 ini
文件中。
那么如何解决呢?
编辑:
即使 curl-ing 它也会得到相同的结果:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode('Administrator:Administrator'),
'Content-Type: image/jpeg'
));
curl_exec($ch);
curl_close($ch);
编辑 2 :
这是来自开发工具的headers:
Request URL: http://tester/nuxeodociframe.php
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:80
Referrer Policy: strict-origin-when-cross-origin
**Response Headers**
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Mon, 11 Jan 2021 13:50:53 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.39 (Win64) PHP/7.2.18
Transfer-Encoding: chunked
X-Powered-By: PHP/7.2.18
**Request Headers**
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Cookie: qa_id=3976046217316149434; qa_noticed=1; RT="z=1&dm=tester&si=9brcldlzx2&ss=kjsghu2u&sl=0&tt=0"; __utma=244493312.1444286480.1610362906.1610362906.1610362906.1; __utmc=244493312; __utmz=244493312.1610362906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host: tester
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
您的浏览器需要知道如何破译它收到的信息。
在这种情况下,您必须“通知”他这是一张图片。
因此,您将添加:
编辑:
在任何 echo
之前添加此行
header("content-type: image/jpeg");
如果图像不是 jpeg,您必须添加合适的 header
同时删除关闭标签?>
有一个API可以用来预览Nuxeo文档;是这样的:
http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image
它应该显示图像内容:
现在我在 file_get_contents
中调用它,但我得到了不可读的内容:
<?php
$opts = [
"http" => [
"method" => "GET",
"header" => array("Authorization: Basic " . base64_encode('Administrator:Administrator'),
"Content-type: image/jpg")
]
];
$context = stream_context_create($opts);
echo file_get_contents("http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image", false, $context);
?>
我尝试使用 gzdecode
但我得到 data error
异常,尽管 magic_quotes_runtime
不存在于 ini
文件中。
那么如何解决呢?
编辑:
即使 curl-ing 它也会得到相同的结果:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/nuxeo/site/api/v1/repo/default/id/563c04bf-897d-48e5-863e-08cebeeccb06/@blob/file:content/@preview/image");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode('Administrator:Administrator'),
'Content-Type: image/jpeg'
));
curl_exec($ch);
curl_close($ch);
编辑 2 :
这是来自开发工具的headers:
Request URL: http://tester/nuxeodociframe.php
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:80
Referrer Policy: strict-origin-when-cross-origin
**Response Headers**
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Mon, 11 Jan 2021 13:50:53 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.39 (Win64) PHP/7.2.18
Transfer-Encoding: chunked
X-Powered-By: PHP/7.2.18
**Request Headers**
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Cookie: qa_id=3976046217316149434; qa_noticed=1; RT="z=1&dm=tester&si=9brcldlzx2&ss=kjsghu2u&sl=0&tt=0"; __utma=244493312.1444286480.1610362906.1610362906.1610362906.1; __utmc=244493312; __utmz=244493312.1610362906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host: tester
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
您的浏览器需要知道如何破译它收到的信息。 在这种情况下,您必须“通知”他这是一张图片。 因此,您将添加:
编辑: 在任何 echo
之前添加此行header("content-type: image/jpeg");
如果图像不是 jpeg,您必须添加合适的 header
同时删除关闭标签?>