Created
January 9, 2009 21:31
-
-
Save latompa/45288 to your computer and use it in GitHub Desktop.
get all keys from a attachment_fu s3 table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You are using attachment_fu and have a database like so | |
id product_id parent_id content_type thumbnail filename | |
1 500 (null) image/png (null) ipod.png | |
2 (null) 1 image/png medium ipod_medium.png | |
3 (null) 1 image/png large ipod_large.png | |
and you want to produce a list of all your s3 urls (for copying a bucket maybe) | |
product_images/1/ipod.jpg | |
product_images/1/ipod_large.jpg | |
product_images/1/ipod_medium.jpg | |
bust out this sql | |
select | |
concat("product_images","/", | |
( cast( | |
if(isnull(parent_id),cast(id as char), cast(parent_id as char)) | |
as char) | |
),"/",filename | |
) | |
from product_images | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment