2012-02-02 138 views
3

这是一个奇怪的 - 我有'几乎'相同的代码在2页上,它可以在一个,但不是另一个。令人难以置信的无用错误消息“S3错误消息”。并没有说明我在哪里出错。ColdFusion ImageWrite到亚马逊S3

下面的代码在两页上都是相同的 - 这两页之间的唯一区别(非常轻微)是imgLink的生成方式 - 在工作页面上从单一来源(XML提要)和cfset获取,在没有工作的页面上imgLink最初设置为'none',然后检查多个源直到它找到一个 - 它仍然以cfset相同的方式,并且我有一个cfif来确保它在处理之前是有效的。但是 - 我也尝试对源代码进行硬编码(即粘贴通常位于imgLink cfset中的值),但仍然失败。

我已经调整了这种方式,我可能会想,在最后一天,没有成功。所以,我想我正在寻找什么我应该看看,可能会导致它失败的指针。

返回完整的错误是 -

进行文件操作时发生错误创建文件S3://mybucket/1577-67BC4EF7-1B21-866F-32E95DF67F3336C6-f.jpg。 此异常的原因是:org.apache.commons.vfs.FileSystemException:未知消息代码..

而且我的代码;“S3错误信息。”

<cfscript> 
     this.name ="Object Operations"; 
     this.s3.accessKeyId = "accessKey"; 
     this.s3.awsSecretKey = "secretKey"; 
     this.s3.defaultLocation="EU"; 
</cfscript> 
<!--- CFImage Stuff ---> 
<!--- S3 Permissions ---> 
<cfset perms = [{group="all", permission="read"}]> 

<!--- Create the Images ----> 
<cfset imageuuid = '#CreateUUID()#'> 
<cfset imagefull = '#getid.id#-#imageuuid#-f.jpg'> 
<cfset imagemain = '#getid.id#-#imageuuid#-m.jpg'> 
<cfset imagethumb = '#getid.id#-#imageuuid#-t.jpg'> 

<cfimage action="read" name="img1" source="#imgLink#"> 

<!--- Create the full size image 505 x N ---> 
<cfif img1.height GT img1.width> 
    <cfif img1.width GTE 505> 
     <cfset ImageResize(img1,'505','')> 
    </cfif> 
<cfelseif img1.width GT img1.height> 
    <cfif img1.width GTE 505> 
     <cfset ImageResize(img1, '505','')> 
    </cfif> 
</cfif> 

<cfset ImageWrite(img1, "s3://mybucket/#imagefull#")> 
<cfset StoreSetACL("s3://mybucket/#imagefull#","#perms#")> 

<!--- Create the main size image 251 x N ---> 
<cfif img1.height GT img1.width> 
    <cfif img1.width GTE 251> 
     <cfset ImageResize(img1,'251','')> 
    </cfif> 
<cfelseif img1.width GT img1.height> 
    <cfif img1.width GTE 251> 
     <cfset ImageResize(img1, '251','')> 
    </cfif> 
</cfif> 

<cfset ImageWrite(img1, "s3://mybucket/#imagemain#")> 
<cfset StoreSetACL("s3://mybucket/#imagemain#","#perms#")> 

<!--- Create the thumbnail 52 x 52 ---> 
<!--- resize image to 52 pixels tall if width is greater then height ---> 
<cfif img1.height GT img1.width> 
    <cfset ImageResize(img1,'52','')> 
    <cfset fromX = img1.Height/2 - 26> 
    <cfset ImageCrop(img1,0,fromX,52,52)> 
<!--- resize image to 75 pixels wide if height is greater then width ---> 
<cfelseif img1.width GT img1.height> 
    <cfset ImageResize(img1,'','52')> 
    <cfset fromY = img1.Width/2 - 26> 
    <cfset ImageCrop(img1,fromY,0,52,52)> 
<cfelse> 
    <cfset ImageResize(img1,'','52')> 
    <cfset ImageCrop(img1,0,0,52,52)> 
</cfif> 

<cfset ImageWrite(img1, "s3://mybucket/#imagethumb#")> 
<cfset StoreSetACL("s3://mybucket/#imagethumb#","#perms#")>  
+0

这是否发生在任何文件或只是特定的图像?我会尝试隔离问题,例如首先在磁盘上写入映像(或者更好地在ram fs中),然后将其作为文件复制到存储桶中。 – Sergii 2012-02-02 11:56:32

+0

@Sergii - 它与所有文件。然而,我刚才发现问题出在哪里 - '没有工作'版本的文件驻留在一个自己的Application.cfc文件夹中。我显然还不能回答我自己的问题,但我会在后面详细介绍发生的事情,为将来寻找其他人的利益。 – Lee 2012-02-02 12:22:13

回答

0

刚刚意识到我没有将我的解决方案,这一点,所以在这里它是 - 在“非工作”的代码是有它自己的Application.cfc,其中不包括文件夹上面的代码中的S3元素。 “工作”代码在相应的Application.cfc中确实存在。

不太清楚为什么必须是在的Application.cfc时,它是在

0

this对象的Application.cfc是ColdFusion页上的application成分,this只是一个结构体变量。将<cfdump var=#this#>放在两个地方,application.cfc和yourfile.cfm中,以查看差异。