使用 API 从 Rackspace CloudFiles 读取文档
我一直在使用 RackSpace CloudFiles 来存储某些图像。我的上传代码运行良好,但是当我尝试从 CloudFiles 读取图像时,它不会显示它。图像不会呈现到浏览器中。该文件肯定正在被读取,因为我可以看到其中的实际数据,但如果我尝试放入标头以将其呈现为图像,则它不起作用。我的代码有错吗?
$auth = new CF_Authentication("x", "x");
$auth->authenticate();
$conn = new CF_Connection($auth);
$cont = $conn->get_container("attachments");
$attachment = $cont->get_object("test.gif");
header("Content-Type: " . $attachment->content_type);
$output = fopen("php://output", "w");
$attachment->stream($output);
fclose($output);
i have been using RackSpace CloudFiles to store certain images. I have the upload code working perfectly but when I try and read the image from CloudFiles it wont display it. The images wont render into the browser. The file is definitely being read as I can see the actual data from it but if I try and put in a header to render it out as an image it doesnt work. Is my code wrong?
$auth = new CF_Authentication("x", "x");
$auth->authenticate();
$conn = new CF_Connection($auth);
$cont = $conn->get_container("attachments");
$attachment = $cont->get_object("test.gif");
header("Content-Type: " . $attachment->content_type);
$output = fopen("php://output", "w");
$attachment->stream($output);
fclose($output);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
排序 - 非常愚蠢的错误!在开始的 php 括号之前有一点空间,这意味着标题之前有输出!傻傻傻
sorted - very silly mistake! had a little space before the opening php bracket meaning there was output before the header! Silly silly silly