2

I am very new to storing pictures on a web server. Currently I am using Google App Engine's Cloud SQL for my database to house all of my user's information (username, password, etc). I was reading about how most people DON'T store pictures in a database.

I was looking at Cloud Storage or Cloud Datastore. I think the route people are taking is to use the Cloud Storage. If that is the case I need help with organizing the storage of the profile pics (user defined) for saving, retrieval, modification and deletion.

My thoughts are: To save a profile pic: Save the .jpg to //profile pic/profile_pic.jpg on the Cloud Storage

I would have /1/profile pics/profile_pic.jpg, /2/profile pics/profile_pic.jpg, /3/profile pic/profile_pic.jpg where the would correspond with the primary key in the database.

Am I on the right track? Is there a standard way to do this that I don't know of?

Any help will be greatly appreciated!!!!

lr100
  • 648
  • 1
  • 9
  • 29
  • In using PHP by the way. Might switch over to python. – lr100 Jul 04 '14 at 21:06
  • I strongly recommend switching to Java. It is statically typed (unlike Python). PHP is well supported but mixes client and server code which is basically a mess. Awaiting downvotes from PHP folks. – Floris Jul 18 '14 at 20:52

2 Answers2

1

There are two different approaches. You described one of them, and it's perfectly fine.

The alternative solution is to save an image in a bucket and remember its key in a database.

Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
1

The best solution by far is to use the Blobstore to save your images and store only the key of your image (and possibly url) in your cloud sql database. If you need sample code, let me know.

Floris
  • 1,082
  • 10
  • 26
  • I would love sample code in PHP. I can't for the life of me figure out what I am doing wrong. Might be code, might be permissions. Not much examples for PHP yet. – lr100 Jul 18 '14 at 14:42
  • Unfortunately I am using Java on GAE but maybe you can explain where you get stuck. Post some code as an edit to your question and I will have a look. I am not sure where you get stuck. Did you manage to upload an image already? Or are you struggling to get the image back? – Floris Jul 18 '14 at 14:53
  • Here is a post a made trying to figure it out. If you need more code let me know. First time doing this ever so I am really in the dark. http://stackoverflow.com/questions/24581280/upload-and-retrieve-image-from-google-cloud-storage-in-php – lr100 Jul 18 '14 at 14:55
  • Seems like you can't use PHP with the Blobstore and must use the Google Cloud Storage for that. See http://stackoverflow.com/questions/16789885/blobstore-on-gae-php. – Floris Jul 18 '14 at 15:05
  • This worked for others: http://stackoverflow.com/questions/22205432/how-do-i-upload-images-to-the-google-cloud-storage-from-php-form But won't work for me: http://stackoverflow.com/questions/24830388/move-uploaded-file-returns-true-but-no-file-in-gcs – lr100 Jul 18 '14 at 17:12