2012-02-02 415 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中,以查看差異。