I have an app that allows users to save blobs in the blobstore. I have a schema that does so presently, but I am interested in something simpler and less twisted. For context, imagine my app allows users to upload the picture of an animal with a paragraph describing what the animal is doing.
Present schema
User calls my endpoint api to save the
paragraphandnameof the animal in entityAnimal. Note: TheAnimalentity actually has 4 fields (name,paragraph,BlobKey, andblobServingUrlas String). But the endpoint api only allows saving of the two mentioned.Within the endpoint method, on app-engine side, after saving
nameandparagraphI make the following call to generate a blob serving url, which my endpoint method returns to the caller@ApiMethod(name = "saveAnimalData", httpMethod = HttpMethod.POST) public String saveAnimalData(AnimalData request) throws Exception { ... BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); String url = blobstoreService.createUploadUrl("/upload"); return url; }
On the android side, I use a normal http call to send the byte[] of the image to the blobstore. I use apache
DefaultHttpClient(). Note: the blobstore, after saving the image, calls my app-engine server with the blob key and serving urlI read the response from the blobstore (blobstore called my callback url) using a normal java servlet, i.e.
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException. From the servlet, I put theBlobKeyandblobServingUrlinto theAnimalentity for the associated animal. (I had passed some meta data to the blobstore, which I use as markers to identify the associated animal entity).
Desired Schema
This is where your response comes in. Essential, I would like to eliminate the java servlet and have my entire api restricted to google cloud endpoint. So my question is: how would I use my endpoint to execute steps 3 and 4?
So the idea would be to send the image bytes to the endpoint method saveAnimalData at the same time that I am sending the paragraph and name data. And then within the endpoint method, send the image to the blobstore and then persist the BlobKey and blobServingUrl in my entity Animal.
Your response must be in java. Thanks.