views:

10

answers:

0

I have a Rails app that processes and serves up jpg files that were uploaded via FTP. On several occasions the FTP process was disconnected and left many incomplete .jpg files. I was surprised to see that the incomplete jpgs behave as normal jpg files in my app even tho they have incomplete image data.

I have since implemented a more robust FTP process where the uploaded file is initially *.tmp and gets renamed to .jpg after an FTP success code is received.

My problem is, I still have all of these incomplete jpg files on the server and can't figure out how to programmatically weed them out. I can actually display them in a view without generating any errors, but there is only a partial image there. I tried RMagick but they all successfully load (using Image.read) and report the valid x & y resolutions. I have so far not been able to determine a way to programmatically differentiate between an incomplete and complete jpg uploaded image.

Any ideas?