tylerhall / Autosmush

Losslessly compresses images in your Amazon S3 buckets on-the-fly.
http://clickontyler.com/blog/2010/10/automatically-compressing-your-amazon-s3-images-using-yahoos-smush-it-service/
121 stars 23 forks source link

getting 'ERROR: Could not download' error.... issue with fopen options. #6

Closed saravk closed 13 years ago

saravk commented 13 years ago

First of all, i'd like to thank you for writing this awesome tool. Looks very useful for my project.

However, when i try to run the script, i get an error saying that the smushed version of the file could not be downloaded. When i checked, i saw that the files created in the /tmp folder have different names from what is expected by the script. They seem to have 6 characters appended to them.. 'smushxyzxyz'. Any idea why this is happening and how to fix this.

FYI.. my server runs rails. So i just installed PHP5, php-curl, the aws sdk and restarted apache. Is there anything else that i should've done here?

root@kettik:~/autosmush# ./autosmush kettik_development SMUSHED: articles/1/coverimgs/c43290a2662ff8fe9fcfe8c352a007bb_cover.jpg (42.50%) ERROR: Could not download smushed version of articles/1/coverimgs/c43290a2662ff8fe9fcfe8c352a007bb_cover.jpg SMUSHED: articles/1/coverimgs/c43290a2662ff8fe9fcfe8c352a007bb_original.jpg (41.76%) ERROR: Could not download smushed version of articles/1/coverimgs/c43290a2662ff8fe9fcfe8c352a007bb_original.jpg SMUSHED: articles/1/coverimgs/c43290a2662ff8fe9fcfe8c352a007bb_small.jpg (66.75%) ^C root@kettik:~/autosmush# ls /tmp passenger.1.0.9956 smushOuXAXx smushPjBKz6 smushqgoJD5

saravk commented 13 years ago

Ok. after some more logs, i realized that the issue is not with the file name. But seems like the smushed file is not downloaded properly.

_ SMUSHED: articles/1/coverimgs/baf85cfca0d1fec5cac974d3c3c818b0_cover.jpg (42.92%) ERROR: Could not download smushed version of articles/1/coverimgs/baf85cfca0d1fec5cac974d3c3c818b0_cover.jpg INFO: Exists: 1, Readable: 1, local filesize 70, Smushed File Size 31583 SMUSHED: articles/1/coverimgs/baf85cfca0d1fec5cac974d3c3c818b0_original.jpg (15.35%) ERROR: Could not download smushed version of articles/1/coverimgs/baf85cfca0d1fec5cac974d3c3c818b0_original.jpg INFO: Exists: 1, Readable: 1, local filesize 70, Smushed File Size 257223

Sometimes the smushed files are updated into my S3 bucket properly. But most times i get the able error.

tylerhall commented 13 years ago

I don't doubt you're seeing an error, but I'm not able to reproduce this. Any other details you can offer?

saravk commented 13 years ago

Finally i managed to get the script working. I changed the fopen option from 'w+' to 'w' and its working fine for me.

$fp = fopen($tmp_filename, 'w');