0

我正在运行Coldfusion8并且有一个处理图像处理的 cfc。

从外部来源抓取图像、将它们放入临时存储、调整大小并保存到 S3 时,cfc 运行良好。我现在尝试通过此 cfc 运行手动上传的一组新图像,突然之间,我遇到了错误。

首先我抓取图像,将其存储在临时目录中,然后调用我的 img_handler:

   <cffile result="temp" action="upload" accept="image/jpeg,image/jpg" filefield="Dateiname8" destination="#variables.tempDirectory#" nameconflict="overwrite" />
    <cfset variables.testFilePath = variables.tempDirectory & temp.serverFile>

    <!--- catch CMYK --->
    <cfimage action="info" source="#variables.testFilePath#" structname="cmyk" />
    <cfif cmyk.colormodel.colorspace EQ "Any of the family of CMYK color spaces">
        <cfthrow type="FileNotFound" message="#tx_settings_icons_error_cymk#" />
    </cfif>
    <cfif structKeyExists( cookie, "resolution")>
        <cfset variables.screenWidth = cookie.resolution>
    <cfelse>
        <cfset variables.screenWidth = "na">
    </cfif>

<!--- call image handler --->
    <cfinvoke component="services.form_img_handler" method="upload" returnVariable="variables.worked">
        <cfinvokeargument name="cm" value="upload_background" />
        <cfinvokeargument name="pt" value="#variables.tempDirectory#" />
        <cfinvokeargument name="fl" value="#temp.serverFile#" />
        <cfinvokeargument name="se" value="#form.app_basic_id#" />
        <cfinvokeargument name="ar" value="background" />
        <cfinvokeargument name="ck" value="#variables.screenWidth#" />
        <cfinvokeargument name="gb" value="" />
        <cfinvokeargument name="ax" value="int" />
        <cfinvokeargument name="al" value="#variables.allow#" />
    </cfinvoke> 

这工作得很好。图像被创建并存储在temp临时文件夹中。我的问题是当我尝试像这样读取 image_handler 中的图像时:

<cfhttp timeout="500" 
    throwonerror="no" 
    url="#LOCAL.tempDirectory##LOCAL.imgFile#" 
    method="get" 
    useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12" 
    getasbinary="yes" 
    result="LOCAL.objGet">

这会产生以下错误:

catch - struct

Charset: [empty string]
ErrorDetail: I/O Exception: For input string: "\website\test\mem\secure\Innentitel.jpg"
Filecontent: Connection Failure
Header: [empty string]
Mimetype: Unable to determine MIME type of file.
Responseheader:  
[struct]
Statuscode: Connection Failure.  Status code unavailable.
Text: YES

我几乎不知道这里发生了什么。

问题
我的应用程序在 SSL 上运行,但是如果我可以在第一步中获取图像并将其存储在 temp 目录中,为什么我无法再次从我的 cfc 中将其拉入。问题可能是我使用的上传功能,access="remote"因为我也将此功能称为网络服务吗?如果是这样,我该怎么做才能让我的函数同时处理remoteregular请求?

感谢帮助!

编辑:
为了澄清,cfinvoke第一个代码块中的第一个代码块调用我的 cfc 来处理所有图像上传到 Amazon S3。在这个 cfc 中,我正在cfhttp拨打有问题的电话。这是我现在使用的方法cfimage,这迫使我在调用 cfc 之前进行所有验证。

<cfcomponent output="false" hint="image handler - s3 manager">

    <cffunction name="Init" access="public" returntype="any" output="false" hint="Initialize">
        <cfreturn true />
    </cffunction>       

    <!--- this is the function I'm calling --->
    <cffunction name="upload" access="remote" output="false" hint="creates images and stores them to S3">
        <cfargument name="cm" type="string" required="true" hint="original form submitted" /> 
        <cfargument name="pt" type="string" required="true" hint="img path" /> 
        <cfargument name="fl" type="string" required="true" hint="img filename" />
        <cfargument name="se" type="string" required="true" hint="user id" />
        <cfargument name="ar" type="string" required="true" hint="item id" />
        <cfargument name="ck" type="string" required="true" hint="screen width" />
        <cfargument name="gb" type="string" required="true" hint="item to send back something" />
        <cfargument name="ax" type="string" required="true" hint="remote call y/n" />
        <cfargument name="al" type="string" required="true" hint="allowed formats or def(ault)" />

        <!--- lot of setters --->       
        <cfscript>  
            var LOCAL = {};
    // arguments
            LOCAL.command = cm;
            LOCAL.imgPath = pt;
            LOCAL.imgFile = fl;
            LOCAL.sellerILN = se;
            LOCAL.article = ar;
            LOCAL.cookie = LSParseNumber(ck);
            LOCAL.getBack = gb;
            LOCAL.access = ax;
            LOCAL.allow = al;

            // command
            if ( LOCAL.command NEQ "" ) {
                LOCAL.action = LOCAL.command;
            } else {
                LOCAL.action = "upload";
            }
            // allow 
            if ( LOCAL.allow EQ "def" ){
                LOCAL.allow = "png,jpg,jpeg";
                } 

            // s3 misc
            LOCAL.letter = "";
            LOCAL.objGet = "";
            LOCAL.bucketPath = Session.bucketPath;
            LOCAL.bucketName = Session.bucketName;
            LOCAL.acl = "public-read";
            LOCAL.storage = "";
            LOCAL.tempDirectory = expandPath( "../somewhere/secure/" );
            LOCAL.failedLoads = "";
            LOCAL.altFailedLoads = "";
            LOCAL.createBucket = "false";
            LOCAL.errorCount = 0;
            LOCAL.altErrorCount = 0;
            LOCAL.cacheControl = 1;
            LOCAL.contentType = "image";
            LOCAL.httptimeout = "300";
            LOCAL.cacheDays = "30";
            LOCAL.storageClass = "REDUCED_REDUNDANCY";
            LOCAL.keyName = "";
            LOCAL.baseUrl = "http://www.page.com";
            LOCAL.imageSrc = "";
            LOCAL.testFilePath = LOCAL.imgPath & LOCAL.imgFile;
            LOCAL.fileExt = ListLast(LOCAL.imgFile, ".");
            LOCAL.runner = "";
            LOCAL.worked = "true";
            LOCAL.or = "";
            LOCAL.tag = "";

            // background dimes - seldomly used, so declare here
            if ( LOCAL.command EQ "upload_background") {
                LOCAL.dims.backW = structNew();
                LOCAL.dims.backW.s = 640;
                LOCAL.dims.backW.m = 800;
                LOCAL.dims.backW.l = 1024;
                LOCAL.dims.backW.xl = 2048;

                LOCAL.dims.backH = structNew();
                LOCAL.dims.backH.s = 480;
                LOCAL.dims.backH.m = 600;
                LOCAL.dims.backH.l = 748;
                LOCAL.dims.backH.xl = 1496;
                }
        </cfscript> 

        <!--- create up to 4 versions of each image and store to S3 --->
        <cftry>
            <cfif LOCAL.command EQ "upload_search">
                <cfif LOCAL.cookie LT 320 >
                    <cfset LOCAL.runner = "l,s">
                <cfelseif LOCAL.cookie GTE 320 AND LOCAL.cookie LTE 767>
                    <cfset LOCAL.runner = "l,m">
                <cfelseif LOCAL.cookie GT 768 AND LOCAL.cookie LTE 1279>
                    <cfset LOCAL.runner = "xl,m">
                <cfelseif LOCAL.cookie GT 1280>
                    <cfset LOCAL.runner = "xl,l">
                </cfif>
            <cfelseif LOCAL.command EQ "upload_import" OR LOCAL.command EQ "upload_background" OR LOCAL.command EQ "remove_background">
                <cfset LOCAL.runner = "xl,l,m,s">
            </cfif>

            <!--- get image --->
            <cfimage action="read" name="LOCAL.objGet" source="#LOCAL.tempDirectory##LOCAL.imgFile#">

            <!--- I/O Exception: peer not authenticated... 
            <cfhttp timeout="500" 
                throwonerror="no" 
                url="https://www.website.com/test/mem/img/secure/#LOCAL.imgFile#" 
                method="get" 
                useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12" 
                getasbinary="yes"
                result="LOCAL.objGet">
            --->        

所以我现在cfimage用来从临时文件夹中检索图像,这与cfhttp. 通话后我进行了图像验证例程cfhttp,现在我将其移至 cfc 调用之外。不确定这是否更好/更智能,但至少它现在正在工作。

4

1 回答 1

1

cfhttp需要带有协议的完整 URL。粗略浏览一下错误消息状态ErrorDetail: I/O Exception: For input string: "\website\test\mem\secure\Innentitel.jpg"

如果您将其转换为带有协议的 URL,它会起作用吗?

于 2012-09-25T06:25:14.187 回答