ColdFusion ImageWrite en Amazon S3

This is a strange one - I have 'virtually' identical code on 2 pages, it works on one but not the other. The incredibly unhelpful error message, "S3 Error Message." doesn't shed any light on where I'm going wrong with this.

The code below is identical on both pages - the only (very slight) difference between the 2 pages is the way imgLink is generated - on the working page it is obtained from a single source (an XML feed) and cfset, on the none-working page imgLink is initially set as 'none' and then a number of sources are checked until it finds one - it's still cfset in the same way, and I have a cfif to make sure it's valid before processing. HOWEVER - I have also tried hardcoding the source (i.e., pasting in the value that would usually be in the imgLink cfset) and it still fails.

I've debugged this in every way I can possibly think in the last day, without success. So, I guess I'm looking for pointers as to what else I should look at that could be causing it to fail.

The full error returned is -

An error occurred when performing a file operation create on file s3://mybucket/1577-67BC4EF7-1B21-866F-32E95DF67F3336C6-f.jpg. The cause of this exception was: org.apache.commons.vfs.FileSystemException: Unknown message with code "S3 Error Message."..

And my code is;

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

<!--- Create the Images ---->
<cfset imageuuid = '#CreateUUID()#'>
<cfset imagefull = ''>
<cfset imagemain = ''>
<cfset imagethumb = ''>

<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','')>
<cfelseif img1.width GT img1.height>
    <cfif img1.width GTE 505>
        <cfset ImageResize(img1, '505','')>

<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','')>
<cfelseif img1.width GT img1.height>
    <cfif img1.width GTE 251>
        <cfset ImageResize(img1, '251','')>

<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)>
    <cfset ImageResize(img1,'','52')>
    <cfset ImageCrop(img1,0,0,52,52)>

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

preguntado el 02 de febrero de 12 a las 10:02

Does this happen with any files or just specific images? I would try to isolate the problem, for example first write image on disk (or better in ram fs) and next copy it as file to the bucket. -

@Sergii - it was with all files. However, I have just figured out where the problem was - the file in the 'none working' version resided in a folder with it's own Application.cfc. I can't answer my own question yet apparently, but I'll post full details of what happened later, for the benefit of others searching in the future. -

2 Respuestas

Just realised I hadn't added my solution to this, so here it is- The folder in which the 'non-working' code was in had it's own Application.cfc, which didn't include the S3 elements in the code posted above. The 'working' code did have that in the corresponding Application.cfc.

Not quite sure why that had to be in Application.cfc when it was at the

Respondido 05 Feb 12, 15:02

El this object in application.cfc is an application componente y this on ColdFusion page is just a structure variable. Put <cfdump var=#this#> in both places, application.cfc and yourfile.cfm, to see the difference.

Respondido el 20 de diciembre de 17 a las 02:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.