使用 API 从 Rackspace CloudFiles 读取文档

发布于 2024-09-09 11:59:35 字数 526 浏览 3 评论 0原文

我一直在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦醒时光 2024-09-16 11:59:36

排序 - 非常愚蠢的错误!在开始的 php 括号之前有一点空间,这意味着标题之前有输出!傻傻傻

sorted - very silly mistake! had a little space before the opening php bracket meaning there was output before the header! Silly silly silly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文