8

I'm trying to create a RESTFul Web Service for upload photos. Is it possible create a Google Cloud Endpoints to upload images/photos? My problem is that I can't understand how to write the function declaration and which parameters I need to handle.

public void uploadPhoto(@Named("token") String token, @Named("title") String title, @Named("description") String description, @Named("photo") HttpServletRequest req) {}

If I handle value of req, what I will find in it? Thank you

computingfreak
  • 4,939
  • 1
  • 34
  • 51
  • I believe you can actually upload directly to gcs. This would probably be simpler and reduce your gae costs. – Tom Aug 17 '14 at 16:57
  • I use BlobStore in the GCS package... My problem is how to upload the file via API... :) The management of the file isn't a problem... – Jiang Cines Wu Aug 17 '14 at 19:42
  • You can found sample and explanations in this other post: http://stackoverflow.com/questions/16510618/is-it-possible-to-create-a-google-app-engine-end-point-which-can-upload-a-photo – olituks Aug 17 '14 at 21:12

1 Answers1

0

The easiest way to do this is store your image as a base64 encoded string. Then you treat it exactly the same way you would any other string in your request.

Once you get it to appengine you can decode the base64 and upload it using the blobstore api as normal.

Note: as some commentators have said uploading directly to GCS may be a more elegant solution.

HJED
  • 957
  • 1
  • 8
  • 16