从图像流式传输 cfcontent?

发布于 2024-12-03 18:46:12 字数 957 浏览 0 评论 0原文

让我在顶部说,我不确定我是否真正理解 cfcontent 在做什么......所以如果这是一个愚蠢的问题,请耐心等待。

我一直在使用 cfcontent 将网络根目录之外的图像流式传输到浏览器。我决定现在要将图像存储在变量中,显示它,能够修改它,查看这些修改,并且仅在我确定我喜欢更改时才提交更改的变量。我想我可以使用 cfcontent 以某种方式从变量流式传输图像,然后从变量显示、修改、重新显示和保存该图像。我的原始代码很简单:

<img id="photoPlaceholder" 
    src="/#application.root_name#/administration/PhotoManagement/displayPhoto.cfm?thisImage=#thisImage#" 
    width="500px" />

并且 displayPhoto.cfm 组成:

<cfcontent type = "image/*" 
    file = "myPathName" 
    deleteFile = "No" />

我看到我可以将文件读入变量并从该变量进行流式传输:

<cffile action="readBinary" file="myPathName" variable="fileObject" />
<cfcontent type="image/*" variable="#fileObject#" />

但是如果我采取创建图像的中间步骤

<cfimage source="fileObject" name="myImage" />
<cfcontent type="image/*" variable="#myImage#" />

,那么我会收到属性验证错误。

有什么想法吗?

Let me just say at the top that I'm not sure I truly understand what cfcontent is doing... so bear with me if this is a stupid question.

I've been using cfcontent to stream images outside of my web root to the browser. I've decided that I now want to store the image in a variable, display it, have the ability to modify it, view those modifications, and only commit the changed variable when I'm sure I like the changes. I was thinking that I could use cfcontent to somehow stream the image from a variable, and then display, modify, re-display, and save that image from the variable. My original code was simply:

<img id="photoPlaceholder" 
    src="/#application.root_name#/administration/PhotoManagement/displayPhoto.cfm?thisImage=#thisImage#" 
    width="500px" />

and displayPhoto.cfm consisted of:

<cfcontent type = "image/*" 
    file = "myPathName" 
    deleteFile = "No" />

I see that I can read the file into a variable and stream from that variable:

<cffile action="readBinary" file="myPathName" variable="fileObject" />
<cfcontent type="image/*" variable="#fileObject#" />

but if I take the intermediate step of creating an image using

<cfimage source="fileObject" name="myImage" />
<cfcontent type="image/*" variable="#myImage#" />

then I get an attribute validation error.

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

青朷 2024-12-10 18:46:12

ImageGetBlob()?

如果你仔细想想 - 这是有道理的。图像变量不是
ColdFusion 中的二进制数据。虽然它们可以存储二进制数据,
ColdFusion 将数据包装在新的“Image”变量类型中。

http://www.coldfusionjedi.com/index.cfm/2007/9/14/Serving-up-CFIMages-via-Image-Tags-and-a-NonCF-Friday-contest

如果您使用的是 CF9,您可以尝试先将映像写入 RAM:// 驱动器,提供服务,然后从 RAM 中删除。

ImageGetBlob()?

If you think about it - this makes sense. Image variables aren't
binary data in ColdFusion. While they may store binary data,
ColdFusion wraps up the data in a new "Image" variable type.

http://www.coldfusionjedi.com/index.cfm/2007/9/14/Serving-up-CFIMages-via-Image-Tags-and-a-NonCF-Friday-contest

If you're using CF9, you can try writing the image to the RAM:// drive first, serve it, and delete from RAM.

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