
So you've been thinking about using Amazon's S3 to store and serve the images for your website. Good idea. It's a good poor-man's Content Delivery Network.
But there's also Google App Engine. Can you store and serve images from there just like S3? Yes. But you need a little python program installed on it first. Oh and unlike S3, Google App Engine is free. If you exceed very large limits you have to pay, but it's free for normal use. With S3 you have to pay for even small use.
Glossy Tooth is an open source project to make Google App Engine work like S3 for storing and serving images. This will reduce your bandwidth bill for hosting images yourself, and make your site faster and better. Is your hosting provider as good as Google for serving up images to people from all over the world? I didn't think so.
Just follow these steps:
Step 1. Clone this git repo http://github.com/andrewarrow/glossy_tooth Step 2. Download and install Google App Engine SDK: http://code.google.com/appengine/downloads.html Step 3. Create a google app engine account: http://appengine.google.com/ and create an application. Name it something. Step 4. Change the application name in app.yaml to the name of your application. Step 5. Deploy your application with the command: appcfg.py update . (or use the GUI) Step 6. Open a browser to: http://yourappname.appspot.com/ You should see "Welcome to glossy_tooth." Step 7. Goto: http://yourappname.appspot.com/upload Upload an image. Leave unique_id blank to have it auto generated for you. Step 8. Use the image with url: http://yourappname.appspot.com/images/3a0110a1-e23b-11de-b88c-69d903d5c500 Replace "3a0110a1-e23b-11de-b88c-69d903d5c500" with your unique_id.
|
|













cool
^^ interesting
Hi,
I installed the demo and had some trouble getting the images to appear in the correct mime type. Content was being returned in text/html, which resulted in binary characters.
I did some research and got it working perfectly with the following changes:
upload.html:
* There was no filename written to the DB. I could see in upload.py that the function was trying to get the filename from the request, but no filename was included. Since the unique_id is the path to the image, I just included a select box in the HTML file that would let the user choose a file type. I store the file type in the filename column in the DB, and it worked great:
<select name="filename">
<option value=".jpg">JPEG</option>
<option value=".png">PNG</option>
<option value=".gif">GIF</option>
</select>
James
Hey James, the filename should be included in the request but not as a separate html form element. It's part of the Content-Disposition line from the multipart/form-data form. The logic parses out the filename. But each file does need to end with .jpg or .png or .gif. If you try and upload an image that's a valid jpg but its name is "picture" with no extension then you won't get a correct mime type. Your solution also works, but is an extra step the user has to do to select the type. The idea was if the image already has the type in the name, use it.